diff --git a/CHANGELOG.md b/CHANGELOG.md index f7c831a..53a8f52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 - 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. +- 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 diff --git a/source/Private/Measure-AuditResult.ps1 b/source/Private/Measure-AuditResult.ps1 index 5d38ec4..4a8b43b 100644 --- a/source/Private/Measure-AuditResult.ps1 +++ b/source/Private/Measure-AuditResult.ps1 @@ -18,8 +18,8 @@ function Measure-AuditResult { $passPercentage = if ($totalTests -eq 0) { 0 } else { [math]::Round(($passedTests / $totalTests) * 100, 2) } # Display the pass percentage to the user - Write-Information "Audit completed. $passedTests out of $totalTests tests passed." - Write-Information "Your passing percentage is $passPercentage%." + Write-Verbose "Audit completed. $passedTests out of $totalTests tests passed." + Write-Verbose "Your passing percentage is $passPercentage%." # Display details of failed tests if ($FailedTests.Count -gt 0) { diff --git a/source/Public/Invoke-M365SecurityAudit.ps1 b/source/Public/Invoke-M365SecurityAudit.ps1 index faa1577..829a368 100644 --- a/source/Public/Invoke-M365SecurityAudit.ps1 +++ b/source/Public/Invoke-M365SecurityAudit.ps1 @@ -225,11 +225,13 @@ function Invoke-M365SecurityAudit { } } elseif ($script:PnpAuth = $true) { + # Ensure MgGraph assemblies are loaded prior to running PnP cmdlets Get-MgGroup -Top 1 -ErrorAction SilentlyContinue | Out-Null } # Load test definitions from CSV $testDefinitionsPath = Join-Path -Path $PSScriptRoot -ChildPath 'helper\TestDefinitions.csv' $testDefinitions = Import-Csv -Path $testDefinitionsPath + # ################ Check for $Version -eq '4.0.0' ################ if ($Version -eq '4.0.0') { $script:Version400 = $true $testDefinitionsV4Path = Join-Path -Path $PSScriptRoot -ChildPath 'helper\TestDefinitions-v4.0.0.csv'