diff --git a/CHANGELOG.md b/CHANGELOG.md index 53a8f52..8ccb8ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ The format is based on and uses the types of changes according to [Keep a Change - 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. +- Get-TestDefinition private function for v4.0.0 to get the test definition for the test. ### Fixed diff --git a/source/Private/Get-TestDefinition.ps1 b/source/Private/Get-TestDefinition.ps1 new file mode 100644 index 0000000..39a70f4 --- /dev/null +++ b/source/Private/Get-TestDefinition.ps1 @@ -0,0 +1,28 @@ +function Get-TestDefinition { + param ( + [string]$Version + ) + # 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' + $testDefinitionsV4 = Import-Csv -Path $testDefinitionsV4Path + # Merge the definitions, prioritizing version 4.0.0 + $mergedDefinitions = @{ } + foreach ($test in $testDefinitions) { + $mergedDefinitions[$test.Rec] = $test + } + foreach ($testV4 in $testDefinitionsV4) { + $mergedDefinitions[$testV4.Rec] = $testV4 # Overwrite if Rec exists + } + # Convert back to an array + $testDefinitions = $mergedDefinitions.Values + Write-Verbose "Total tests after merging: $(($testDefinitions).Count)" + $overwrittenTests = $testDefinitionsV4 | Where-Object { $testDefinitions[$_.Rec] } + Write-Verbose "Overwritten tests: $($overwrittenTests.Rec -join ', ')" + } + return $testDefinitions +}