diff --git a/CHANGELOG.md b/CHANGELOG.md index eb97558e47..9f828872b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,13 +2,19 @@ # UNRELEASED +* AADApplication + * Refactored logic for CIM Instance evaluation in Test-TargetResource. * AADConditionalAccessPolicy * Changed the InsiderRiskTypes property to a string array. +* AADGroup + * Refactored logic for CIM Instance evaluation in Test-TargetResource. * AADServicePrincipal * Fixes comparison of assigned roles for null values. FIXES [#5717](https://github.com/microsoft/Microsoft365DSC/issues/5717) * CommerceSelfServicePurchase * Initial release. +* SCRoleGroupMember + * Error handling if the Members parameter is omitted. * MISC * Changed the CIMInstance logic of various resources to us common logic. * Added support for specifying a proxy in Update-M365DSCModule. diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAdminConsentRequestPolicy/MSFT_AADAdminConsentRequestPolicy.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAdminConsentRequestPolicy/MSFT_AADAdminConsentRequestPolicy.psm1 index 77ebe8e3ec..81ef4cb4d9 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAdminConsentRequestPolicy/MSFT_AADAdminConsentRequestPolicy.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAdminConsentRequestPolicy/MSFT_AADAdminConsentRequestPolicy.psm1 @@ -358,32 +358,45 @@ function Test-TargetResource $CurrentValues = Get-TargetResource @PSBoundParameters $ValuesToCheck = ([Hashtable]$PSBoundParameters).Clone() + $testTargetResource = $true Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)" - $testResult = $true - foreach ($reviewer in $Reviewers) + #Compare Cim instances + foreach ($key in $PSBoundParameters.Keys) { - $currentEquivalent = $CurrentValues.Reviewers | Where-Object -FilterScript { $_.ReviewerId -eq $reviewer.ReviewerId -and $_.ReviewerType -eq $reviewer.ReviewerType } - if ($null -eq $currentEquivalent) - { - $testResult = $false - Write-Verbose -Message "Couldn't find current reviewer {$($reviewer.ReviewerId)}" - } + $source = $PSBoundParameters.$key + $target = $CurrentValues.$key + if ($null -ne $source -and $source.GetType().Name -like '*CimInstance*') + { + $testResult = Compare-M365DSCComplexObject ` + -Source ($source) ` + -Target ($target) + + if (-not $testResult) + { + Write-Verbose "TestResult returned False for $source" + $testTargetResource = $false + } + else + { + $ValuesToCheck.Remove($key) | Out-Null + } + } } - if ($testResult) + $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck $ValuesToCheck.Keys + + if (-not $TestResult) { - $ValuesToCheck.Remove('Reviewers') | Out-Null - $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` - -Source $($MyInvocation.MyCommand.Source) ` - -DesiredValues $PSBoundParameters ` - -ValuesToCheck $ValuesToCheck.Keys + $testTargetResource = $false } + Write-Verbose -Message "Test-TargetResource returned $testTargetResource" - Write-Verbose -Message "Test-TargetResource returned $testResult" - - return $testResult + return $testTargetResource } function Export-TargetResource diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADApplication/MSFT_AADApplication.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADApplication/MSFT_AADApplication.psm1 index 193e7ac6d0..446ac091a5 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADApplication/MSFT_AADApplication.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADApplication/MSFT_AADApplication.psm1 @@ -455,11 +455,15 @@ function Get-TargetResource # singleSignOnSettings $singleSignOnValues = @{ - kerberosSignOnSettings = @{ + singleSignOnMode = $oppInfo.singleSignOnSettings.singleSignOnMode + } + if ($oppInfo.singleSignOnMode.kerberosSignOnSettings) + { + $kerberosSignOnSettings = @{ kerberosServicePrincipalName = $oppInfo.singleSignOnSettings.kerberosSignOnSettings.kerberosServicePrincipalName kerberosSignOnMappingAttributeType = $oppInfo.singleSignOnSettings.kerberosSignOnSettings.kerberosSignOnMappingAttributeType } - singleSignOnMode = $oppInfo.singleSignOnSettings.singleSignOnMode + $singleSignOnValues.Add('kerberosSignOnSettings', $kerberosSignOnSettings) } $onPremisesPublishingValue.Add('singleSignOnSettings', $singleSignOnValues) } @@ -1415,50 +1419,7 @@ function Test-TargetResource Write-Verbose -Message 'Testing configuration of AzureAD Application' $CurrentValues = Get-TargetResource @PSBoundParameters - - if ($CurrentValues.Permissions.Length -gt 0 -and $null -ne $CurrentValues.Permissions.Name -and ` - $null -ne $Permissions) - { - $differenceObject = $Permissions.Name - if ($null -eq $differenceObject) - { - $differenceObject = @() - } - $permissionsDiff = Compare-Object -ReferenceObject ($CurrentValues.Permissions.Name) -DifferenceObject $differenceObject - $driftedParams = @{} - if ($null -ne $permissionsDiff) - { - Write-Verbose -Message "Permissions differ: $($permissionsDiff | Out-String)" - Write-Verbose -Message "Test-TargetResource returned $false" - $EventValue = "$($CurrentValues.Permissions.Name)" - $EventValue += "$($Permissions.Name)" - $driftedParams.Add('Permissions', $EventValue) - } - else - { - Write-Verbose -Message 'Permissions for Azure AD Application are the same' - } - } - else - { - $driftedParams = @{} - if ($Permissions.Length -gt 0) - { - Write-Verbose -Message 'No Permissions exist for the current Azure AD App, but permissions were specified for desired state' - Write-Verbose -Message "Test-TargetResource returned $false" - - $EventValue = "`$null" - $EventValue += "$($Permissions.Name)" - $driftedParams.Add('Permissions', $EventValue) - } - else - { - Write-Verbose -Message 'No Permissions exist for the current Azure AD App and no permissions were specified' - } - } - $ValuesToCheck = ([Hashtable]$PSBoundParameters).clone() - $testTargetResource = $true #Compare Cim instances @@ -1466,7 +1427,7 @@ function Test-TargetResource { $source = $PSBoundParameters.$key $target = $CurrentValues.$key - if ($null -ne $source -and $source.GetType().Name -like '*CimInstance*' -and $source -notlike '*Permission*') + if ($null -ne $source -and $source.GetType().Name -like '*CimInstance*') { $testResult = Compare-M365DSCComplexObject ` -Source ($source) ` @@ -1489,7 +1450,6 @@ function Test-TargetResource $ValuesToCheck.Remove('ObjectId') | Out-Null $ValuesToCheck.Remove('AppId') | Out-Null - $ValuesToCheck.Remove('Permissions') | Out-Null $TestResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` -Source $($MyInvocation.MyCommand.Source) ` diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicy/MSFT_AADAuthenticationMethodPolicy.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicy/MSFT_AADAuthenticationMethodPolicy.psm1 index f7e9ea30e0..5fe37db211 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicy/MSFT_AADAuthenticationMethodPolicy.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicy/MSFT_AADAuthenticationMethodPolicy.psm1 @@ -508,6 +508,7 @@ function Test-TargetResource $CurrentValues = Get-TargetResource @PSBoundParameters $ValuesToCheck = ([Hashtable]$PSBoundParameters).clone() $testResult = $true + $testTargetResource = $true #Compare Cim instances foreach ($key in $PSBoundParameters.Keys) @@ -518,7 +519,7 @@ function Test-TargetResource { $source = Get-M365DSCDRGComplexTypeToHashtable -ComplexObject $source - $testResult = Compare-M365DSCComplexObject ` + $testTargetResource = Compare-M365DSCComplexObject ` -Source ($source) ` -Target ($target) @@ -537,17 +538,17 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)" - if ($testResult) + $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck $ValuesToCheck.Keys + + if (-not $TestResult) { - $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` - -Source $($MyInvocation.MyCommand.Source) ` - -DesiredValues $PSBoundParameters ` - -ValuesToCheck $ValuesToCheck.Keys + $testTargetResource = $false } - - Write-Verbose -Message "Test-TargetResource returned $testResult" - - return $testResult + Write-Verbose -Message "Test-TargetResource returned $testTargetResource" + return $testTargetResource } function Export-TargetResource diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyAuthenticator/MSFT_AADAuthenticationMethodPolicyAuthenticator.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyAuthenticator/MSFT_AADAuthenticationMethodPolicyAuthenticator.psm1 index 22a9b92b6b..718c596575 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyAuthenticator/MSFT_AADAuthenticationMethodPolicyAuthenticator.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyAuthenticator/MSFT_AADAuthenticationMethodPolicyAuthenticator.psm1 @@ -789,6 +789,7 @@ function Test-TargetResource $CurrentValues = Get-TargetResource @PSBoundParameters $ValuesToCheck = ([Hashtable]$PSBoundParameters).clone() $testResult = $true + $testTargetResource = $true #Compare Cim instances foreach ($key in $PSBoundParameters.Keys) @@ -805,7 +806,7 @@ function Test-TargetResource if (-Not $testResult) { - $testResult = $false + $testTargetResource = $false break } @@ -818,17 +819,18 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)" - if ($testResult) + $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck $ValuesToCheck.Keys + + if (-not $TestResult) { - $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` - -Source $($MyInvocation.MyCommand.Source) ` - -DesiredValues $PSBoundParameters ` - -ValuesToCheck $ValuesToCheck.Keys + $testTargetResource = $false } + Write-Verbose -Message "Test-TargetResource returned $testTargetResource" - Write-Verbose -Message "Test-TargetResource returned $testResult" - - return $testResult + return $testTargetResource } function Export-TargetResource diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyEmail/MSFT_AADAuthenticationMethodPolicyEmail.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyEmail/MSFT_AADAuthenticationMethodPolicyEmail.psm1 index 446b1aeda4..8a36cdb0d9 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyEmail/MSFT_AADAuthenticationMethodPolicyEmail.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyEmail/MSFT_AADAuthenticationMethodPolicyEmail.psm1 @@ -453,6 +453,7 @@ function Test-TargetResource $CurrentValues = Get-TargetResource @PSBoundParameters $ValuesToCheck = ([Hashtable]$PSBoundParameters).clone() $testResult = $true + $testTargetResource = $true #Compare Cim instances foreach ($key in $PSBoundParameters.Keys) @@ -469,7 +470,7 @@ function Test-TargetResource if (-Not $testResult) { - $testResult = $false + $testTargetResource = $false break } @@ -482,17 +483,18 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)" - if ($testResult) + $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck $ValuesToCheck.Keys + + if (-not $TestResult) { - $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` - -Source $($MyInvocation.MyCommand.Source) ` - -DesiredValues $PSBoundParameters ` - -ValuesToCheck $ValuesToCheck.Keys + $testTargetResource = $false } + Write-Verbose -Message "Test-TargetResource returned $testTargetResource" - Write-Verbose -Message "Test-TargetResource returned $testResult" - - return $testResult + return $testTargetResource } function Export-TargetResource diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyExternal/MSFT_AADAuthenticationMethodPolicyExternal.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyExternal/MSFT_AADAuthenticationMethodPolicyExternal.psm1 index 3d165e0f60..23ce0be271 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyExternal/MSFT_AADAuthenticationMethodPolicyExternal.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyExternal/MSFT_AADAuthenticationMethodPolicyExternal.psm1 @@ -439,6 +439,7 @@ function Test-TargetResource $CurrentValues = Get-TargetResource @PSBoundParameters $ValuesToCheck = ([Hashtable]$PSBoundParameters).clone() $testResult = $true + $testTargetResource = $true #Compare Cim instances foreach ($key in $PSBoundParameters.Keys) @@ -455,7 +456,7 @@ function Test-TargetResource if (-Not $testResult) { - $testResult = $false + $testTargetResource = $false break } @@ -466,17 +467,18 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)" - if ($testResult) + $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck $ValuesToCheck.Keys + + if (-not $TestResult) { - $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` - -Source $($MyInvocation.MyCommand.Source) ` - -DesiredValues $PSBoundParameters ` - -ValuesToCheck $ValuesToCheck.Keys + $testTargetResource = $false } + Write-Verbose -Message "Test-TargetResource returned $testTargetResource" - Write-Verbose -Message "Test-TargetResource returned $testResult" - - return $testResult + return $testTargetResource } function Export-TargetResource diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyFido2/MSFT_AADAuthenticationMethodPolicyFido2.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyFido2/MSFT_AADAuthenticationMethodPolicyFido2.psm1 index f7582a366b..00d2df7dfc 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyFido2/MSFT_AADAuthenticationMethodPolicyFido2.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyFido2/MSFT_AADAuthenticationMethodPolicyFido2.psm1 @@ -483,6 +483,7 @@ function Test-TargetResource $testResult = $true #Compare Cim instances + $testTargetResource = $true foreach ($key in $PSBoundParameters.Keys) { $source = $PSBoundParameters.$key @@ -497,7 +498,7 @@ function Test-TargetResource if (-Not $testResult) { - $testResult = $false + $testTargetResource = $false break } @@ -510,17 +511,18 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)" - if ($testResult) + $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck $ValuesToCheck.Keys + + if (-not $TestResult) { - $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` - -Source $($MyInvocation.MyCommand.Source) ` - -DesiredValues $PSBoundParameters ` - -ValuesToCheck $ValuesToCheck.Keys + $testTargetResource = $false } + Write-Verbose -Message "Test-TargetResource returned $testTargetResource" - Write-Verbose -Message "Test-TargetResource returned $testResult" - - return $testResult + return $testTargetResource } function Export-TargetResource diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyHardware/MSFT_AADAuthenticationMethodPolicyHardware.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyHardware/MSFT_AADAuthenticationMethodPolicyHardware.psm1 index 723b4f0a83..1d85e1d98c 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyHardware/MSFT_AADAuthenticationMethodPolicyHardware.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyHardware/MSFT_AADAuthenticationMethodPolicyHardware.psm1 @@ -425,6 +425,7 @@ function Test-TargetResource $CurrentValues = Get-TargetResource @PSBoundParameters $ValuesToCheck = ([Hashtable]$PSBoundParameters).clone() $testResult = $true + $testTargetResource = $true #Compare Cim instances foreach ($key in $PSBoundParameters.Keys) @@ -441,7 +442,7 @@ function Test-TargetResource if (-Not $testResult) { - $testResult = $false + $testTargetResource = $false break } @@ -454,17 +455,17 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)" - if ($testResult) + $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck $ValuesToCheck.Keys + + if (-not $TestResult) { - $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` - -Source $($MyInvocation.MyCommand.Source) ` - -DesiredValues $PSBoundParameters ` - -ValuesToCheck $ValuesToCheck.Keys + $testTargetResource = $false } - - Write-Verbose -Message "Test-TargetResource returned $testResult" - - return $testResult + Write-Verbose -Message "Test-TargetResource returned $testTargetResource" + return $testTargetResource } function Export-TargetResource diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicySms/MSFT_AADAuthenticationMethodPolicySms.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicySms/MSFT_AADAuthenticationMethodPolicySms.psm1 index 188fdcc9b9..c1d4ed5197 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicySms/MSFT_AADAuthenticationMethodPolicySms.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicySms/MSFT_AADAuthenticationMethodPolicySms.psm1 @@ -429,6 +429,7 @@ function Test-TargetResource $CurrentValues = Get-TargetResource @PSBoundParameters $ValuesToCheck = ([Hashtable]$PSBoundParameters).clone() $testResult = $true + $testTargetResource = $true #Compare Cim instances foreach ($key in $PSBoundParameters.Keys) @@ -445,7 +446,7 @@ function Test-TargetResource if (-Not $testResult) { - $testResult = $false + $testTargetResource = $false break } @@ -458,17 +459,17 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)" - if ($testResult) + $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck $ValuesToCheck.Keys + + if (-not $TestResult) { - $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` - -Source $($MyInvocation.MyCommand.Source) ` - -DesiredValues $PSBoundParameters ` - -ValuesToCheck $ValuesToCheck.Keys + $testTargetResource = $false } - - Write-Verbose -Message "Test-TargetResource returned $testResult" - - return $testResult + Write-Verbose -Message "Test-TargetResource returned $testTargetResource" + return $testTargetResource } function Export-TargetResource diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicySoftware/MSFT_AADAuthenticationMethodPolicySoftware.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicySoftware/MSFT_AADAuthenticationMethodPolicySoftware.psm1 index 7d8bd7934c..07a0658607 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicySoftware/MSFT_AADAuthenticationMethodPolicySoftware.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicySoftware/MSFT_AADAuthenticationMethodPolicySoftware.psm1 @@ -428,6 +428,7 @@ function Test-TargetResource $CurrentValues = Get-TargetResource @PSBoundParameters $ValuesToCheck = ([Hashtable]$PSBoundParameters).clone() $testResult = $true + $testTargetResource = $true #Compare Cim instances foreach ($key in $PSBoundParameters.Keys) @@ -444,7 +445,7 @@ function Test-TargetResource if (-Not $testResult) { - $testResult = $false + $testTargetResource = $false break } @@ -457,17 +458,17 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)" - if ($testResult) + $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck $ValuesToCheck.Keys + + if (-not $TestResult) { - $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` - -Source $($MyInvocation.MyCommand.Source) ` - -DesiredValues $PSBoundParameters ` - -ValuesToCheck $ValuesToCheck.Keys + $testTargetResource = $false } - - Write-Verbose -Message "Test-TargetResource returned $testResult" - - return $testResult + Write-Verbose -Message "Test-TargetResource returned $testTargetResource" + return $testTargetResource } function Export-TargetResource diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyTemporary/MSFT_AADAuthenticationMethodPolicyTemporary.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyTemporary/MSFT_AADAuthenticationMethodPolicyTemporary.psm1 index 1ad824f844..72881fe434 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyTemporary/MSFT_AADAuthenticationMethodPolicyTemporary.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyTemporary/MSFT_AADAuthenticationMethodPolicyTemporary.psm1 @@ -497,6 +497,7 @@ function Test-TargetResource $CurrentValues = Get-TargetResource @PSBoundParameters $ValuesToCheck = ([Hashtable]$PSBoundParameters).clone() $testResult = $true + $testTargetResource = $true #Compare Cim instances Write-Verbose -Message 'Evaluating keys' @@ -514,7 +515,7 @@ function Test-TargetResource if (-Not $testResult) { - $testResult = $false + $testTargetResource = $false break } @@ -527,17 +528,17 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)" - if ($testResult) + $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck $ValuesToCheck.Keys + + if (-not $TestResult) { - $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` - -Source $($MyInvocation.MyCommand.Source) ` - -DesiredValues $PSBoundParameters ` - -ValuesToCheck $ValuesToCheck.Keys + $testTargetResource = $false } - - Write-Verbose -Message "Test-TargetResource returned $testResult" - - return $testResult + Write-Verbose -Message "Test-TargetResource returned $testTargetResource" + return $testTargetResource } function Export-TargetResource diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyVoice/MSFT_AADAuthenticationMethodPolicyVoice.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyVoice/MSFT_AADAuthenticationMethodPolicyVoice.psm1 index bde2d43b71..d77839ccfb 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyVoice/MSFT_AADAuthenticationMethodPolicyVoice.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyVoice/MSFT_AADAuthenticationMethodPolicyVoice.psm1 @@ -441,6 +441,7 @@ function Test-TargetResource $CurrentValues = Get-TargetResource @PSBoundParameters $ValuesToCheck = ([Hashtable]$PSBoundParameters).clone() $testResult = $true + $testTargetResource = $true #Compare Cim instances foreach ($key in $PSBoundParameters.Keys) @@ -457,7 +458,7 @@ function Test-TargetResource if (-Not $testResult) { - $testResult = $false + $testTargetResource = $false break } @@ -470,17 +471,17 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)" - if ($testResult) + $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck $ValuesToCheck.Keys + + if (-not $TestResult) { - $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` - -Source $($MyInvocation.MyCommand.Source) ` - -DesiredValues $PSBoundParameters ` - -ValuesToCheck $ValuesToCheck.Keys + $testTargetResource = $false } - - Write-Verbose -Message "Test-TargetResource returned $testResult" - - return $testResult + Write-Verbose -Message "Test-TargetResource returned $testTargetResource" + return $testTargetResource } function Export-TargetResource diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyX509/MSFT_AADAuthenticationMethodPolicyX509.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyX509/MSFT_AADAuthenticationMethodPolicyX509.psm1 index 46edf9edb9..c3b23dc7d0 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyX509/MSFT_AADAuthenticationMethodPolicyX509.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyX509/MSFT_AADAuthenticationMethodPolicyX509.psm1 @@ -505,6 +505,7 @@ function Test-TargetResource $CurrentValues = Get-TargetResource @PSBoundParameters $ValuesToCheck = ([Hashtable]$PSBoundParameters).clone() $testResult = $true + $testTargetResource = $true #Compare Cim instances foreach ($key in $PSBoundParameters.Keys) @@ -521,7 +522,7 @@ function Test-TargetResource if (-Not $testResult) { - $testResult = $false + $testTargetResource = $false break } @@ -534,17 +535,17 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)" - if ($testResult) + $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck $ValuesToCheck.Keys + + if (-not $TestResult) { - $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` - -Source $($MyInvocation.MyCommand.Source) ` - -DesiredValues $PSBoundParameters ` - -ValuesToCheck $ValuesToCheck.Keys + $testTargetResource = $false } - - Write-Verbose -Message "Test-TargetResource returned $testResult" - - return $testResult + Write-Verbose -Message "Test-TargetResource returned $testTargetResource" + return $testTargetResource } function Export-TargetResource diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationRequirement/MSFT_AADAuthenticationRequirement.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationRequirement/MSFT_AADAuthenticationRequirement.psm1 index bcb1ce332d..8ab33aa514 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationRequirement/MSFT_AADAuthenticationRequirement.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationRequirement/MSFT_AADAuthenticationRequirement.psm1 @@ -243,21 +243,16 @@ function Test-TargetResource $CurrentValues = Get-TargetResource @PSBoundParameters $ValuesToCheck = ([Hashtable]$PSBoundParameters).Clone() - $testResult = $true - $CurrentValues.remove('Id') | Out-Null $ValuesToCheck.remove('Id') | Out-Null Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)" - if ($testResult) - { - $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` - -Source $($MyInvocation.MyCommand.Source) ` - -DesiredValues $PSBoundParameters ` - -ValuesToCheck $ValuesToCheck.Keys - } + $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck $ValuesToCheck.Keys Write-Verbose -Message "Test-TargetResource returned $testResult" diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationStrengthPolicy/MSFT_AADAuthenticationStrengthPolicy.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationStrengthPolicy/MSFT_AADAuthenticationStrengthPolicy.psm1 index 1f31b32475..b6574a5ca9 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationStrengthPolicy/MSFT_AADAuthenticationStrengthPolicy.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationStrengthPolicy/MSFT_AADAuthenticationStrengthPolicy.psm1 @@ -299,18 +299,14 @@ function Test-TargetResource $CurrentValues = Get-TargetResource @PSBoundParameters $ValuesToCheck = ([Hashtable]$PSBoundParameters).clone() $ValuesToCheck.Remove('Id') | Out-Null - $testResult = $true Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)" - if ($testResult) - { - $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` - -Source $($MyInvocation.MyCommand.Source) ` - -DesiredValues $PSBoundParameters ` - -ValuesToCheck $ValuesToCheck.Keys - } + $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck $ValuesToCheck.Keys Write-Verbose -Message "Test-TargetResource returned $testResult" diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADClaimsMappingPolicy/MSFT_AADClaimsMappingPolicy.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADClaimsMappingPolicy/MSFT_AADClaimsMappingPolicy.psm1 index 0e69584348..2929e98968 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADClaimsMappingPolicy/MSFT_AADClaimsMappingPolicy.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADClaimsMappingPolicy/MSFT_AADClaimsMappingPolicy.psm1 @@ -416,6 +416,7 @@ function Test-TargetResource $CurrentValues = Get-TargetResource @PSBoundParameters $ValuesToCheck = ([Hashtable]$PSBoundParameters).clone() $testResult = $true + $testTargetResource = $true #Compare Cim instances foreach ($key in $PSBoundParameters.Keys) @@ -430,6 +431,7 @@ function Test-TargetResource if (-not $testResult) { + $testTargetResource = $false break } @@ -443,17 +445,17 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)" - if ($testResult) + $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck $ValuesToCheck.Keys + + if (-not $TestResult) { - $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` - -Source $($MyInvocation.MyCommand.Source) ` - -DesiredValues $PSBoundParameters ` - -ValuesToCheck $ValuesToCheck.Keys + $testTargetResource = $false } - - Write-Verbose -Message "Test-TargetResource returned $testResult" - - return $testResult + Write-Verbose -Message "Test-TargetResource returned $testTargetResource" + return $testTargetResource } function Export-TargetResource diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADConditionalAccessPolicy/MSFT_AADConditionalAccessPolicy.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADConditionalAccessPolicy/MSFT_AADConditionalAccessPolicy.psm1 index ca02585337..20c557d1a8 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADConditionalAccessPolicy/MSFT_AADConditionalAccessPolicy.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADConditionalAccessPolicy/MSFT_AADConditionalAccessPolicy.psm1 @@ -2208,43 +2208,63 @@ function Test-TargetResource [System.String[]] $AccessTokens ) + #Ensure the proper dependencies are installed in the current environment. + Confirm-M365DSCDependencies + + #region Telemetry + $ResourceName = $MyInvocation.MyCommand.ModuleName.Replace('MSFT_', '') + $CommandName = $MyInvocation.MyCommand + $data = Format-M365DSCTelemetryParameters -ResourceName $ResourceName ` + -CommandName $CommandName ` + -Parameters $PSBoundParameters + Add-M365DSCTelemetryEvent -Data $data + #endregion Write-Verbose -Message 'Testing configuration of AzureAD CA Policies' $CurrentValues = Get-TargetResource @PSBoundParameters + $ValuesToCheck = ([Hashtable]$PSBoundParameters).clone() + $testResult = $true + $testTargetResource = $true - Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" - Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $PSBoundParameters)" + #Compare Cim instances + foreach ($key in $PSBoundParameters.Keys) + { + $source = $PSBoundParameters.$key + $target = $CurrentValues.$key + if ($null -ne $source -and $source.GetType().Name -like '*CimInstance*') + { + $testResult = Compare-M365DSCComplexObject ` + -Source ($source) ` + -Target ($target) - $ValuesToCheck = $PSBoundParameters - $ValuesToCheck.Remove('Id') | Out-Null + if (-not $testResult) + { + $testTargetResource = $false + break + } - # If no TransferMethod is specified, ignore it - # If a TransferMethod is specified, check if it is equal to the current value - # while ignoring the order of the values - if (-not $PSBoundParameters.ContainsKey('TransferMethods') -or - $null -eq (Compare-Object -ReferenceObject $TransferMethods.Split(',') -DifferenceObject $CurrentValues.TransferMethods.Split(','))) - { - $ValuesToCheck.Remove('TransferMethods') | Out-Null - $TestResult = $true - } - else - { - Write-Verbose -Message "TransferMethods are not equal: [$TransferMethods] - [$($CurrentValues.TransferMethods)]" - $TestResult = $false + $ValuesToCheck.Remove($key) | Out-Null + } } - if ($TestResult) - { - $TestResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` - -Source $($MyInvocation.MyCommand.Source) ` - -DesiredValues $PSBoundParameters ` - -ValuesToCheck $ValuesToCheck.Keys - } + $ValuesToCheck.Remove('Id') | Out-Null + $ValuesToCheck = Remove-M365DSCAuthenticationParameter -BoundParameters $ValuesToCheck - Write-Verbose -Message "Test-TargetResource returned $TestResult" + Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" + Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)" - return $TestResult + $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck $ValuesToCheck.Keys + + if (-not $TestResult) + { + $testTargetResource = $false + } + Write-Verbose -Message "Test-TargetResource returned $testTargetResource" + return $testTargetResource } function Export-TargetResource diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADConnectorGroupApplicationProxy/MSFT_AADConnectorGroupApplicationProxy.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADConnectorGroupApplicationProxy/MSFT_AADConnectorGroupApplicationProxy.psm1 index ccbbbd5ffc..cf9bfcb2d4 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADConnectorGroupApplicationProxy/MSFT_AADConnectorGroupApplicationProxy.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADConnectorGroupApplicationProxy/MSFT_AADConnectorGroupApplicationProxy.psm1 @@ -326,13 +326,10 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)" - if ($testResult) - { - $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` - -Source $($MyInvocation.MyCommand.Source) ` - -DesiredValues $PSBoundParameters ` - -ValuesToCheck $ValuesToCheck.Keys - } + $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck $ValuesToCheck.Keys Write-Verbose -Message "Test-TargetResource returned $testResult" diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADCrossTenantAccessPolicyConfigurationDefault/MSFT_AADCrossTenantAccessPolicyConfigurationDefault.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADCrossTenantAccessPolicyConfigurationDefault/MSFT_AADCrossTenantAccessPolicyConfigurationDefault.psm1 index e4983b150a..5851e16ace 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADCrossTenantAccessPolicyConfigurationDefault/MSFT_AADCrossTenantAccessPolicyConfigurationDefault.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADCrossTenantAccessPolicyConfigurationDefault/MSFT_AADCrossTenantAccessPolicyConfigurationDefault.psm1 @@ -350,6 +350,7 @@ function Test-TargetResource $CurrentValues = Get-TargetResource @PSBoundParameters $ValuesToCheck = ([Hashtable]$PSBoundParameters).clone() $testResult = $true + $testTargetResource = $true #Compare Cim instances foreach ($key in $PSBoundParameters.Keys) @@ -367,7 +368,7 @@ function Test-TargetResource if (-Not $testResult) { Write-Verbose -Message "Difference found for $key" - $testResult = $false + $testTargetResource = $false break } @@ -378,17 +379,17 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)" - if ($testResult) + $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck $ValuesToCheck.Keys + + if (-not $TestResult) { - $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` - -Source $($MyInvocation.MyCommand.Source) ` - -DesiredValues $PSBoundParameters ` - -ValuesToCheck $ValuesToCheck.Keys + $testTargetResource = $false } - - Write-Verbose -Message "Test-TargetResource returned $testResult" - - return $testResult + Write-Verbose -Message "Test-TargetResource returned $testTargetResource" + return $testTargetResource } function Export-TargetResource diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADCrossTenantAccessPolicyConfigurationPartner/MSFT_AADCrossTenantAccessPolicyConfigurationPartner.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADCrossTenantAccessPolicyConfigurationPartner/MSFT_AADCrossTenantAccessPolicyConfigurationPartner.psm1 index 73af68b8ec..1c6ac48434 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADCrossTenantAccessPolicyConfigurationPartner/MSFT_AADCrossTenantAccessPolicyConfigurationPartner.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADCrossTenantAccessPolicyConfigurationPartner/MSFT_AADCrossTenantAccessPolicyConfigurationPartner.psm1 @@ -385,6 +385,7 @@ function Test-TargetResource $CurrentValues = Get-TargetResource @PSBoundParameters $ValuesToCheck = ([Hashtable]$PSBoundParameters).clone() $testResult = $true + $testTargetResource = $true #Compare Cim instances foreach ($key in $PSBoundParameters.Keys) @@ -402,7 +403,7 @@ function Test-TargetResource if (-Not $testResult) { Write-Verbose -Message "Difference found for $key" - $testResult = $false + $testTargetResource = $false break } @@ -413,17 +414,17 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)" - if ($testResult) + $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck $ValuesToCheck.Keys + + if (-not $TestResult) { - $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` - -Source $($MyInvocation.MyCommand.Source) ` - -DesiredValues $PSBoundParameters ` - -ValuesToCheck $ValuesToCheck.Keys + $testTargetResource = $false } - - Write-Verbose -Message "Test-TargetResource returned $testResult" - - return $testResult + Write-Verbose -Message "Test-TargetResource returned $testTargetResource" + return $testTargetResource } function Export-TargetResource diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADCustomAuthenticationExtension/MSFT_AADCustomAuthenticationExtension.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADCustomAuthenticationExtension/MSFT_AADCustomAuthenticationExtension.psm1 index 368dc4b401..6232ccaf5f 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADCustomAuthenticationExtension/MSFT_AADCustomAuthenticationExtension.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADCustomAuthenticationExtension/MSFT_AADCustomAuthenticationExtension.psm1 @@ -498,6 +498,7 @@ function Test-TargetResource $CurrentValues = Get-TargetResource @PSBoundParameters $ValuesToCheck = ([Hashtable]$PSBoundParameters).Clone() + $testTargetResource = $true #Compare Cim instances foreach ($key in $PSBoundParameters.Keys) @@ -530,9 +531,12 @@ function Test-TargetResource -DesiredValues $PSBoundParameters ` -ValuesToCheck $ValuesToCheck.Keys - Write-Verbose -Message "Test-TargetResource returned $testResult" - - return $testResult + if (-not $TestResult) + { + $testTargetResource = $false + } + Write-Verbose -Message "Test-TargetResource returned $testTargetResource" + return $testTargetResource } function Export-TargetResource diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADGroup/MSFT_AADGroup.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADGroup/MSFT_AADGroup.psm1 index eb80eb01e7..3adde8eeb7 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADGroup/MSFT_AADGroup.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADGroup/MSFT_AADGroup.psm1 @@ -1065,128 +1065,47 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $PSBoundParameters)" - # Check Licenses - if (-not ($null -eq $AssignedLicenses -and $null -eq $CurrentValues.AssignedLicenses)) + $ValuesToCheck = ([Hashtable]$PSBoundParameters).clone() + $ValuesToCheck.Remove('Id') | Out-Null + + $testTargetResource = $true + + #Compare Cim instances + foreach ($key in $PSBoundParameters.Keys) { - try + $source = $PSBoundParameters.$key + $target = $CurrentValues.$key + if ($null -ne $source -and $source.GetType().Name -like '*CimInstance*') { - if ($null -ne $CurrentValues.AssignedLicenses -and $CurrentValues.AssignedLicenses.Length -gt 0 -and ` - ($PSBoundParameters.ContainsKey('AssignedLicenses') -and $null -eq $AssignedLicenses)) - { - Write-Verbose -Message "The group {$DisplayName} currently has licenses assigned but it shouldn't" - Write-Verbose -Message "Test-TargetResource returned $false" - $EventMessage = "Assigned Licenses for Azure AD Group {$DisplayName} were not in the desired state.`r`nThe group should not have any licenses assigned but instead contained {$($CurrentValues.AssignedLicenses.SkuId -join ',')}" - Add-M365DSCEvent -Message $EventMessage -EntryType 'Warning' ` - -EventID 1 -Source $($MyInvocation.MyCommand.Source) + $testResult = Compare-M365DSCComplexObject ` + -Source ($source) ` + -Target ($target) - return $false - } - elseif ($null -eq $CurrentValues.AssignedLicenses -and $null -ne $AssignedLicenses -and ` - $AssignedLicenses.Length -gt 0) + if (-not $testResult) { - Write-Verbose -Message "The group {$DisplayName} currently doesn't have licenses assigned but it should" - Write-Verbose -Message "Test-TargetResource returned $false" - $EventMessage = "Assigned Licenses for Azure AD Group {$DisplayName} were not in the desired state.`r`nThe group doesn't not have any licenses assigned but should have {$($CurrentValues.AssignedLicenses.SkuId -join ',')}" - Add-M365DSCEvent -Message $EventMessage -EntryType 'Warning' ` - -EventID 1 -Source $($MyInvocation.MyCommand.Source) - - return $false - } - elseif ($CurrentValues.AssignedLicenses.Length -gt 0 -and $AssignedLicenses.Length -gt 0) - { - Write-Verbose -Message "Current assigned licenses and desired assigned licenses for group {$DisplayName} are not null and will be compared" - $licensesDiff = Compare-Object -ReferenceObject ($CurrentValues.AssignedLicenses.SkuId) -DifferenceObject ($AssignedLicenses.SkuId) - if ($null -ne $licensesDiff) - { - Write-Verbose -Message "AssignedLicenses differ for group {$DisplayName}: $($licensesDiff | Out-String)" - Write-Verbose -Message "Test-TargetResource returned $false" - $EventMessage = "Assigned Licenses for Azure AD Group {$DisplayName} were not in the desired state.`r`nThey should contain {$($AssignedLicenses.SkuId -join ',')} but instead contained {$($CurrentValues.AssignedLicenses.SkuId -join ',')}" - Add-M365DSCEvent -Message $EventMessage -EntryType 'Warning' ` - -EventID 1 -Source $($MyInvocation.MyCommand.Source) - - return $false - } - else - { - Write-Verbose -Message "AssignedLicenses for Azure AD Group {$DisplayName} are the same, checking DisabledPlans" - } - - # Disabled Plans - #Compare DisabledPlans for each SkuId - all SkuId's are processed regardless of result - $result = $true - foreach ($assignedLicense in $AssignedLicenses) - { - Write-Verbose "Compare DisabledPlans for SkuId $($assignedLicense.SkuId) in group {$DisplayName}" - $currentLicense = $CurrentValues.AssignedLicenses | Where-Object -FilterScript { $_.SkuId -eq $assignedLicense.SkuId } - if ($assignedLicense.DisabledPlans.Count -ne 0 -or $currentLicense.DisabledPlans.Count -ne 0) - { - try - { - $licensesDiff = Compare-Object -ReferenceObject $assignedLicense.DisabledPlans -DifferenceObject $currentLicense.DisabledPlans - if ($null -ne $licensesDiff) - { - Write-Verbose -Message "DisabledPlans for SkuId $($assignedLicense.SkuId) differ: $($licensesDiff | Out-String)" - Write-Verbose -Message "Test-TargetResource returned $false" - $EventMessage = "Disabled Plans for Azure AD Group Licenses {$DisplayName} SkuId $($assignedLicense.SkuId) were not in the desired state.`r`n" + ` - "They should contain {$($assignedLicense.DisabledPlans -join ',')} but instead contained {$($currentLicense.DisabledPlans -join ',')}" - Add-M365DSCEvent -Message $EventMessage -EntryType 'Warning' ` - -EventID 1 -Source $($MyInvocation.MyCommand.Source) - - $result = $false - } - else - { - Write-Verbose -Message "DisabledPlans for SkuId $($assignedLicense.SkuId) are the same" - } - } - catch - { - Write-Verbose -Message "Test-TargetResource returned `$false (DisabledPlans: $($_.Exception.Message))" - $result = $false - } - } - } - if ($true -ne $result) - { - return $result - } - } - elseif ($PSBoundParameters.ContainsKey('AssignedLicenses')) - { - Write-Verbose -Message "The group {$DisplayName} currently has licenses assigned but it shouldn't have" - Write-Verbose -Message "Test-TargetResource returned $false" - $EventMessage = "Assigned Licenses for Azure AD Group {$DisplayName} were not in the desired state.`r`nThe group has licenses assigned but shouldn't have {$($CurrentValues.AssignedLicenses.SkuId)}" - Add-M365DSCEvent -Message $EventMessage -EntryType 'Warning' ` - -EventID 1 -Source $($MyInvocation.MyCommand.Source) - - return $false + Write-Verbose "TestResult returned False for $source" + $testTargetResource = $false } else { - Write-Verbose -Message "Both the current and desired assigned licenses lists for group {$DisplayName} are empty or not specified." + $ValuesToCheck.Remove($key) | Out-Null } } - catch - { - Write-Verbose -Message "Error evaluating the AssignedLicenses for group {$DisplayName}: $_" - Write-Verbose -Message "Test-TargetResource returned $false" - return $false - } } - $ValuesToCheck = $PSBoundParameters - $ValuesToCheck.Remove('Id') | Out-Null - $ValuesToCheck.Remove('GroupTypes') | Out-Null - $ValuesToCheck.Remove('AssignedLicenses') | Out-Null - $TestResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck $ValuesToCheck.Keys - Write-Verbose -Message "Test-TargetResource returned $TestResult" + if (-not $TestResult) + { + $testTargetResource = $false + } + + Write-Verbose -Message "Test-TargetResource returned $testTargetResource" - return $TestResult + return $testTargetResource } function Export-TargetResource diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADIdentityGovernanceLifecycleWorkflowCustomTaskExtension/MSFT_AADIdentityGovernanceLifecycleWorkflowCustomTaskExtension.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADIdentityGovernanceLifecycleWorkflowCustomTaskExtension/MSFT_AADIdentityGovernanceLifecycleWorkflowCustomTaskExtension.psm1 index d911ffb734..1ab23ab5eb 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADIdentityGovernanceLifecycleWorkflowCustomTaskExtension/MSFT_AADIdentityGovernanceLifecycleWorkflowCustomTaskExtension.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADIdentityGovernanceLifecycleWorkflowCustomTaskExtension/MSFT_AADIdentityGovernanceLifecycleWorkflowCustomTaskExtension.psm1 @@ -389,6 +389,7 @@ function Test-TargetResource $CurrentValues = Get-TargetResource @PSBoundParameters $ValuesToCheck = ([Hashtable]$PSBoundParameters).Clone() + $testTargetResource = $true Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)" @@ -405,23 +406,30 @@ function Test-TargetResource if (-not $testResult) { - break + Write-Verbose "TestResult returned False for $source" + $testTargetResource = $false + } + else + { + $ValuesToCheck.Remove($key) | Out-Null } - - $ValuesToCheck.Remove($key) | Out-Null } } - if ($testResult) - { - $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` - -Source $($MyInvocation.MyCommand.Source) ` - -DesiredValues $PSBoundParameters ` - -ValuesToCheck $ValuesToCheck.Keys - } - Write-Verbose -Message "Test-TargetResource returned $testResult" + Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" + Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)" + + $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck $ValuesToCheck.Keys - return $testResult + if (-not $TestResult) + { + $testTargetResource = $false + } + Write-Verbose -Message "Test-TargetResource returned $testTargetResource" + return $testTargetResource } function Export-TargetResource diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_SCRoleGroupMember/MSFT_SCRoleGroupMember.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_SCRoleGroupMember/MSFT_SCRoleGroupMember.psm1 index 64e0ac78e1..bf15678b89 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_SCRoleGroupMember/MSFT_SCRoleGroupMember.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_SCRoleGroupMember/MSFT_SCRoleGroupMember.psm1 @@ -90,12 +90,21 @@ function Get-TargetResource } # Get RoleGroup Members if RoleGroup exists. - $roleGroupMember = Get-RoleGroupMember -Identity $Name | Select-Object Name + $roleGroupMembers = Get-RoleGroupMember -Identity $Name | Select-Object Name + + if ($roleGroupMembers.Length -eq 0) + { + $roleGroupMembersValue = @() + } + else + { + $roleGroupMembersValue = $roleGroupMembers.Name + } $result = @{ Name = $RoleGroup.Name Description = $RoleGroup.Description - Members = $roleGroupMember.Name + Members = $roleGroupMembersValue Ensure = 'Present' Credential = $Credential ApplicationId = $ApplicationId @@ -193,10 +202,23 @@ function Set-TargetResource -InboundParameters $PSBoundParameters # CASE: Role Group has different member values than the desired ones - if ($Ensure -eq 'Present' -and $currentRoleGroupConfig.Ensure -eq 'Present' -and $null -ne (Compare-Object -ReferenceObject $($currentRoleGroupConfig.Members) -DifferenceObject $Members)) + $MembersValue = $Members + if ([System.String]::IsNullOrEmpty($Members)) + { + $MembersValue = @() + } + + $currentMembersValue = $currentRoleGroupConfig.Members + if ([System.String]::IsNullOrEmpty($currentRoleGroupConfig.Members)) + { + $currentMembersValue = @() + } + + $differences = Compare-Object -ReferenceObject $currentMembersValue -DifferenceObject $MembersValue + + if ($Ensure -eq 'Present' -and $currentRoleGroupConfig.Ensure -eq 'Present' -and $null -ne $differences) { Write-Verbose -Message "Role Group '$($Name)' exists, but members need updating." - $differences = Compare-Object -ReferenceObject $($currentRoleGroupConfig.Members) -DifferenceObject $Members foreach ($difference in $differences) { if ($difference.SideIndicator -eq '=>') @@ -294,6 +316,7 @@ function Test-TargetResource Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $PSBoundParameters)" $ValuesToCheck = $PSBoundParameters + $ValuesToCheck.Remove('Description') | Out-Null $TestResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` -Source $($MyInvocation.MyCommand.Source) ` diff --git a/Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1 index 4f82942a31..538080fda8 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1 @@ -659,19 +659,49 @@ function Compare-M365DSCComplexObject foreach ($item in $Source) { + $foundMatch = $false foreach ($targetItem in $Target) { - $compareResult = Compare-M365DSCComplexObject ` - -Source $item ` - -Target $targetItem + if (-not $foundMatch) + { + $compareResult = Compare-M365DSCComplexObject ` + -Source $item ` + -Target $targetItem + + if ($compareResult) + { + $foundMatch = $true + } + } + } + + if (-not $foundMatch) + { + Write-Verbose -Message 'Configuration drift - The complex array items are not identical' + return $false + } + } - if ($compareResult) + # Do the opposite check + foreach ($item in $target) + { + $foundMatch = $false + foreach ($targetItem in $Source) + { + if (-not $foundMatch) { - break + $compareResult = Compare-M365DSCComplexObject ` + -Source $item ` + -Target $targetItem + + if ($compareResult) + { + $foundMatch = $true + } } } - if (-not $compareResult) + if (-not $foundMatch) { Write-Verbose -Message 'Configuration drift - The complex array items are not identical' return $false @@ -720,121 +750,130 @@ function Compare-M365DSCComplexObject foreach ($key in $keys) { - #Matching possible key names between Source and Target - $sourceValue = $Source.$key - - # Some classes might contain default properties that have the same name as the key, - # so we need to check if the key is present in the target object --> Hashtable <-> IsReadOnly property - if ($key -in $targetKeys) + if (($target.GetType().Name -eq 'Hashtable' -and $target.ContainsKey($key)) -or ` + ($target.GetType().Name -eq 'CIMInstance' -and $null -ne $target.$key)) { - $targetValue = $Target.$key - } - else - { - $targetValue = $null - } + #Matching possible key names between Source and Target + $sourceValue = $Source.$key - #One of the item is null and not the other - if (($Source.$key.Length -eq 0) -xor ($targetValue.Length -eq 0)) - { - if ($null -eq $Source.$key) + # Some classes might contain default properties that have the same name as the key, + # so we need to check if the key is present in the target object --> Hashtable <-> IsReadOnly property + if ($key -in $targetKeys) { - $sourceValue = 'null' + $targetValue = $Target.$key } - - if ($null -eq $targetValue) + else { - $targetValue = 'null' + $targetValue = $null } - Write-Verbose -Message "Configuration drift - key: $key" - Write-Verbose -Message "Source {$sourceValue}" - Write-Verbose -Message "Target {$targetValue}" - return $false - } - - #Both keys aren't null or empty - if (($null -ne $Source.$key) -and ($null -ne $Target.$key)) - { - if ($Source.$key.GetType().FullName -like '*CimInstance*' -or $Source.$key.GetType().FullName -like '*hashtable*') + #One of the item is null and not the other + if (($Source.$key.Length -eq 0) -xor ($targetValue.Length -eq 0)) { - if ($Source.$key.GetType().FullName -like '*CimInstance' -and ( - $Source.$key.CimClass.CimClassName -eq 'MSFT_DeviceManagementConfigurationPolicyAssignments' -or - $Source.$key.CimClass.CimClassName -like 'MSFT_DeviceManagementMobileAppAssignment' -or - $Source.$key.CimClass.CimClassName -like 'MSFT_Intune*Assignments' - )) + if ($null -eq $Source.$key) { - $compareResult = Compare-M365DSCIntunePolicyAssignment ` - -Source @($Source.$key) ` - -Target @($Target.$key) - } - else - { - #Recursive call for complex object - $compareResult = Compare-M365DSCComplexObject ` - -Source $Source.$key ` - -Target $Target.$key + $sourceValue = 'null' } - if (-not $compareResult) + if ($null -eq $targetValue) { - Write-Verbose -Message "Configuration drift - complex object key: $key" - Write-Verbose -Message "Source {$sourceValue}" - Write-Verbose -Message "Target {$targetValue}" - return $false + $targetValue = 'null' } + + Write-Verbose -Message "Configuration drift - key: $key" + Write-Verbose -Message "Source {$sourceValue}" + Write-Verbose -Message "Target {$targetValue}" + return $false } - else - { - #Simple object comparison - $referenceObject = $Target.$key - $differenceObject = $Source.$key - #Identifying date from the current values - $targetType = ($Target.$key.GetType()).Name - if ($targetType -like '*Date*') + #Both keys aren't null or empty + if (($null -ne $Source.$key) -and ($null -ne $Target.$key)) + { + if ($Source.$key.GetType().FullName -like '*CimInstance*' -or $Source.$key.GetType().FullName -like '*hashtable*' -or ` + $Source.$key.GetType().Name -eq 'Object[]') { - $compareResult = $true - $sourceDate = [DateTime]$Source.$key - if ($sourceDate -ne $targetType) + if ($Source.$key.GetType().FullName -like '*CimInstance' -and ( + $Source.$key.CimClass.CimClassName -eq 'MSFT_DeviceManagementConfigurationPolicyAssignments' -or + $Source.$key.CimClass.CimClassName -like 'MSFT_DeviceManagementMobileAppAssignment' -or + $Source.$key.CimClass.CimClassName -like 'MSFT_Intune*Assignments' + )) + { + $compareResult = Compare-M365DSCIntunePolicyAssignment ` + -Source @($Source.$key) ` + -Target @($Target.$key) + } + else { - $compareResult = $null + #Recursive call for complex object + $compareResult = Compare-M365DSCComplexObject ` + -Source $Source.$key ` + -Target $Target.$key + } + + if (-not $compareResult) + { + Write-Verbose -Message "Configuration drift - complex object key: $key" + Write-Verbose -Message "Source {$sourceValue}" + Write-Verbose -Message "Target {$targetValue}" + return $false } } - elseif ($targetType -eq 'String') + else { - # Align line breaks - if (-not [System.String]::IsNullOrEmpty($referenceObject)) + #Simple object comparison + $referenceObject = $Target.$key + $differenceObject = $Source.$key + + #Identifying date from the current values + $targetType = ($Target.$key.GetType()).Name + if ($targetType -like '*Date*') { - $referenceObject = $referenceObject.Replace("`r`n", "`n") + $compareResult = $true + $sourceDate = [DateTime]$Source.$key + if ($sourceDate -ne $targetType) + { + $compareResult = $null + } } + elseif ($targetType -eq 'String') + { + # Align line breaks + if (-not [System.String]::IsNullOrEmpty($referenceObject)) + { + $referenceObject = $referenceObject.Replace("`r`n", "`n") + } + + if (-not [System.String]::IsNullOrEmpty($differenceObject)) + { + $differenceObject = $differenceObject.Replace("`r`n", "`n") + } - if (-not [System.String]::IsNullOrEmpty($differenceObject)) + $compareResult = $true + $ordinalComparison = [System.String]::Equals($referenceObject, $differenceObject, [System.StringComparison]::Ordinal) + if (-not $ordinalComparison) + { + $compareResult = $false + } + elseif ($ordinalComparison) + { + $compareResult = $null + } + } + else { - $differenceObject = $differenceObject.Replace("`r`n", "`n") + $compareResult = Compare-Object ` + -ReferenceObject ($referenceObject) ` + -DifferenceObject ($differenceObject) } - $compareResult = $true - $ordinalComparison = [System.String]::Equals($referenceObject, $differenceObject, [System.StringComparison]::Ordinal) - if ($ordinalComparison) + if ($null -ne $compareResult -and $compareResult.Length -gt 0) { - $compareResult = $null + Write-Verbose -Message "Configuration drift - simple object key: $key" + Write-Verbose -Message "Source {$sourceValue}" + Write-Verbose -Message "Target {$targetValue}" + return $false } } - else - { - $compareResult = Compare-Object ` - -ReferenceObject ($referenceObject) ` - -DifferenceObject ($differenceObject) - } - - if ($null -ne $compareResult) - { - Write-Verbose -Message "Configuration drift - simple object key: $key" - Write-Verbose -Message "Source {$sourceValue}" - Write-Verbose -Message "Target {$targetValue}" - return $false - } } } } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADAdminConsentRequestPolicy.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADAdminConsentRequestPolicy.Tests.ps1 index 8c913408a9..ffdc8e6f41 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADAdminConsentRequestPolicy.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADAdminConsentRequestPolicy.Tests.ps1 @@ -65,7 +65,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } - $Script:exportedInstances =$null + $Script:exportedInstance =$null $Script:ExportMode = $false } # Test contexts @@ -157,7 +157,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { IsEnabled = $true NotifyReviewers = $False; RemindersEnabled = $True; - RequestDurationInDays = 30; + RequestDurationInDays = 29; #drift Reviewers = @( @{ Query = "/v1.0/users/e362df2b-8f61-4e5a-9e5e-c6069f3ed2ee" diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADAuthenticationMethodPolicyEmail.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADAuthenticationMethodPolicyEmail.Tests.ps1 index 28aa707b8c..c589de3da5 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADAuthenticationMethodPolicyEmail.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADAuthenticationMethodPolicyEmail.Tests.ps1 @@ -40,7 +40,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } - $Script:exportedInstances =$null + $Script:exportedInstance =$null $Script:ExportMode = $false } # Test contexts @@ -257,7 +257,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { } ) Id = "Email" - State = "enabled" + State = "disabled" #drift } } } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADAuthenticationMethodPolicyHardware.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADAuthenticationMethodPolicyHardware.Tests.ps1 index 0e851d7849..038e750eed 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADAuthenticationMethodPolicyHardware.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADAuthenticationMethodPolicyHardware.Tests.ps1 @@ -40,7 +40,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } - $Script:exportedInstances =$null + $Script:exportedInstance =$null $Script:ExportMode = $false } # Test contexts @@ -250,7 +250,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { } ) Id = "HardwareOath" - State = "enabled" + State = "disabled" #drift } } } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADAuthenticationMethodPolicySms.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADAuthenticationMethodPolicySms.Tests.ps1 index 4f17ec150d..a74168d1f9 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADAuthenticationMethodPolicySms.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADAuthenticationMethodPolicySms.Tests.ps1 @@ -40,7 +40,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } - $Script:exportedInstances =$null + $Script:exportedInstance =$null $Script:ExportMode = $false } # Test contexts @@ -250,7 +250,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { } ) Id = "Sms" - State = "enabled" + State = "disabled" #drift } } } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADAuthenticationMethodPolicySoftware.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADAuthenticationMethodPolicySoftware.Tests.ps1 index a3cb95ca17..8ce780ab86 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADAuthenticationMethodPolicySoftware.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADAuthenticationMethodPolicySoftware.Tests.ps1 @@ -40,7 +40,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } - $Script:exportedInstances =$null + $Script:exportedInstance =$null $Script:ExportMode = $false } # Test contexts @@ -250,7 +250,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { } ) Id = "SoftwareOath" - State = "enabled" + State = "disabled" #drift } } } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADAuthenticationMethodPolicyX509.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADAuthenticationMethodPolicyX509.Tests.ps1 index a717fc5802..c66f82f913 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADAuthenticationMethodPolicyX509.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADAuthenticationMethodPolicyX509.Tests.ps1 @@ -40,7 +40,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } - $Script:exportedInstances =$null + $Script:exportedInstance =$null $Script:ExportMode = $false } # Test contexts @@ -361,7 +361,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { } ) Id = "X509Certificate" - State = "enabled" + State = "disabled" #drift } } } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADClaimsMappingPolicy.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADClaimsMappingPolicy.Tests.ps1 index a462d49748..4b0dc9bbd7 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADClaimsMappingPolicy.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADClaimsMappingPolicy.Tests.ps1 @@ -49,7 +49,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } - $Script:exportedInstances =$null + $Script:exportedInstance =$null $Script:ExportMode = $false } # Test contexts diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADCrossTenantAccessPolicyConfigurationDefault.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADCrossTenantAccessPolicyConfigurationDefault.Tests.ps1 index 762fca96ae..a2fd67819d 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADCrossTenantAccessPolicyConfigurationDefault.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADCrossTenantAccessPolicyConfigurationDefault.Tests.ps1 @@ -50,7 +50,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } - $Script:exportedInstances =$null + $Script:exportedInstance =$null $Script:ExportMode = $false } # Test contexts diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADIdentityGovernanceLifecycleWorkflowCustomTaskExtension.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADIdentityGovernanceLifecycleWorkflowCustomTaskExtension.Tests.ps1 index cf2811f30c..a82cc21fc1 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADIdentityGovernanceLifecycleWorkflowCustomTaskExtension.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADIdentityGovernanceLifecycleWorkflowCustomTaskExtension.Tests.ps1 @@ -51,7 +51,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } - $Script:exportedInstances =$null + $Script:exportedInstance = $null $Script:ExportMode = $false } # Test contexts