fix: pre test call

This commit is contained in:
DrIOS
2025-04-19 19:33:22 -05:00
parent 6cb086f8f1
commit 445c962af0
3 changed files with 6 additions and 2 deletions

View File

@@ -21,6 +21,8 @@ The format is based on and uses the types of changes according to [Keep a Change
- Adds new CSV for PowerShell commands and updates PnP update check handling - Adds new CSV for PowerShell commands and updates PnP update check handling
- Introduces a new CSV file listing various PowerShell commands for different Microsoft services. - Introduces a new CSV file listing various PowerShell commands for different Microsoft services.
- Updates the `Invoke-M365SecurityAudit` script to temporarily disable PnP PowerShell update checks during execution and restores the original setting afterward. - Updates the `Invoke-M365SecurityAudit` script to temporarily disable PnP PowerShell update checks during execution and restores the original setting afterward.
- Pre-Test cmdlet call to `Get-MgGroup` to load the MgGraph assembly prior to running PnP PowerShell commands when using app authentication.
- Output Verbosity for test score.
### Fixed ### Fixed

View File

@@ -18,8 +18,8 @@ function Measure-AuditResult {
$passPercentage = if ($totalTests -eq 0) { 0 } else { [math]::Round(($passedTests / $totalTests) * 100, 2) } $passPercentage = if ($totalTests -eq 0) { 0 } else { [math]::Round(($passedTests / $totalTests) * 100, 2) }
# Display the pass percentage to the user # Display the pass percentage to the user
Write-Information "Audit completed. $passedTests out of $totalTests tests passed." Write-Verbose "Audit completed. $passedTests out of $totalTests tests passed."
Write-Information "Your passing percentage is $passPercentage%." Write-Verbose "Your passing percentage is $passPercentage%."
# Display details of failed tests # Display details of failed tests
if ($FailedTests.Count -gt 0) { if ($FailedTests.Count -gt 0) {

View File

@@ -225,11 +225,13 @@ function Invoke-M365SecurityAudit {
} }
} }
elseif ($script:PnpAuth = $true) { elseif ($script:PnpAuth = $true) {
# Ensure MgGraph assemblies are loaded prior to running PnP cmdlets
Get-MgGroup -Top 1 -ErrorAction SilentlyContinue | Out-Null Get-MgGroup -Top 1 -ErrorAction SilentlyContinue | Out-Null
} }
# Load test definitions from CSV # Load test definitions from CSV
$testDefinitionsPath = Join-Path -Path $PSScriptRoot -ChildPath 'helper\TestDefinitions.csv' $testDefinitionsPath = Join-Path -Path $PSScriptRoot -ChildPath 'helper\TestDefinitions.csv'
$testDefinitions = Import-Csv -Path $testDefinitionsPath $testDefinitions = Import-Csv -Path $testDefinitionsPath
# ################ Check for $Version -eq '4.0.0' ################
if ($Version -eq '4.0.0') { if ($Version -eq '4.0.0') {
$script:Version400 = $true $script:Version400 = $true
$testDefinitionsV4Path = Join-Path -Path $PSScriptRoot -ChildPath 'helper\TestDefinitions-v4.0.0.csv' $testDefinitionsV4Path = Join-Path -Path $PSScriptRoot -ChildPath 'helper\TestDefinitions-v4.0.0.csv'