Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IntuneAppConfigurationPolicy: Fix comparison in Test-TargetResource #4452

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

# UNRELEASED

* IntuneAppConfigurationPolicy
* Fix comparison in Test-TargetResource
FIXES [#4451](https://github.com/microsoft/Microsoft365DSC/issues/4451)
* DEPENDENCIES
* Updated DSCParser to version 2.0.0.0.

Expand Down Expand Up @@ -88,7 +91,7 @@
Get-TargetResource
* Fixed an issue with the parameter InterfaceTypes from firewallrules defined
as a string instead of string[]
* IntuneDeviceConfigurationPKCSCertificatePolicyWindows10
* IntuneDeviceConfigurationSCEPCertificatePolicyWindows10
* Add property RootCertificateDisplayName in order to support assigning root
certificates by display name since their Ids in a blueprint might be from a
different source tenant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,48 +365,40 @@ function Test-TargetResource
Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)"
Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $PSBoundParameters)"

$testResult = $true
if ($CurrentValues.Ensure -ne $PSBoundParameters.Ensure)
{
$testResult = $false
Write-Verbose -Message "Test-TargetResource returned $false"
return $false
}
$testResult = $true

$ValuesToCheck = $PSBoundParameters
$ValuesToCheck.Remove('Credential') | Out-Null
$ValuesToCheck.Remove('ApplicationId') | Out-Null
$ValuesToCheck.Remove('TenantId') | Out-Null
$ValuesToCheck.Remove('ApplicationSecret') | Out-Null
$ValuesToCheck.Remove('CustomSettings') | Out-Null

#region CustomSettings
if ($testResult)
#Compare Cim instances
foreach ($key in $PSBoundParameters.Keys)
{
$source = $PSBoundParameters.CustomSettings
$target = $CurrentValues.CustomSettings
$source = $PSBoundParameters.$key
$target = $CurrentValues.$key
if ($source.getType().Name -like '*CimInstance*')
{
$source = Get-M365DSCDRGComplexTypeToHashtable -ComplexObject $source

$source = Get-M365DSCDRGComplexTypeToHashtable -ComplexObject $source
$testResult = Compare-M365DSCComplexObject `
-Source ($source) `
-Target ($target)
$testResult = Compare-M365DSCComplexObject `
-Source ($source) `
-Target ($target)

if (-Not $testResult)
{
$testResult = $false
break
}
$ValuesToCheck.Remove('CustomSettings') | Out-Null
}
#endregion
if ($key -eq 'Assignments')
{
$testResult = Compare-M365DSCIntunePolicyAssignment -Source $source -Target $target
}

#region Assignments
if ($testResult)
{
$source = Get-M365DSCDRGComplexTypeToHashtable -ComplexObject $PSBoundParameters.Assignments
$target = $CurrentValues.Assignments
$testResult = Compare-M365DSCIntunePolicyAssignment -Source $source -Target $target
$ValuesToCheck.Remove('Assignments') | Out-Null
if (-Not $testResult)
{
$testResult = $false
break
}

$ValuesToCheck.Remove($key) | Out-Null
}
}
#endregion

if ($testResult)
{
Expand All @@ -415,6 +407,7 @@ function Test-TargetResource
-DesiredValues $PSBoundParameters `
-ValuesToCheck $ValuesToCheck.Keys
}

Write-Verbose -Message "Test-TargetResource returned $TestResult"

return $TestResult
Expand Down
Loading