Add: Get-TestDefinition function
This commit is contained in:
@@ -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.
|
- 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.
|
- 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.
|
- Output Verbosity for test score.
|
||||||
|
- Get-TestDefinition private function for v4.0.0 to get the test definition for the test.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|||||||
28
source/Private/Get-TestDefinition.ps1
Normal file
28
source/Private/Get-TestDefinition.ps1
Normal file
@@ -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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user