add: add score to console host

This commit is contained in:
DrIOS
2024-05-30 16:41:38 -05:00
parent 87d0aaaea6
commit 399288b10a
2 changed files with 13 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ The format is based on and uses the types of changes according to [Keep a Change
- Test definitions filter function.
- Logging function for future use.
- Test grade written to console.
### Changed

View File

@@ -228,6 +228,18 @@ function Invoke-M365SecurityAudit {
# Clean up sessions
Disconnect-M365Suite -RequiredConnections $requiredConnections
}
# Calculate the total number of tests
$totalTests = $allAuditResults.Count
# Calculate the number of passed tests
$passedTests = $allAuditResults.ToArray() | Where-Object { $_.Result -eq $true } | Measure-Object | Select-Object -ExpandProperty Count
# Calculate the pass percentage
$passPercentage = if ($totalTests -eq 0) { 0 } else { [math]::Round(($passedTests / $totalTests) * 100, 2) }
# Display the pass percentage to the user
Write-Host "Audit completed. $passedTests out of $totalTests tests passed." -ForegroundColor Cyan
Write-Host "Your passing percentage is $passPercentage%."
# Return all collected audit results
return $allAuditResults.ToArray()
# Check if the Disconnect switch is present