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

IntuneDeviceConfigurationPolicyAndroidOpenSourceProject: Fixed policy assignment retrieval when Id is from other tenant, bogus or null #4399

Merged
merged 6 commits into from
Mar 12, 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
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@
* EXOHostedContentFilterRule
* Fixed issue in case of different names of filter rule and filter policy
FIXES [#4401](https://github.com/microsoft/Microsoft365DSC/issues/4401)
* IntuneDeviceConfigurationScepCertificatePolicyWindows10
* IntuneDeviceConfigurationPKCSCertificatePolicyWindows10
* 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
FIXES [#3965](https://github.com/microsoft/Microsoft365DSC/issues/3965)
* IntuneDeviceConfigurationPolicyAndroidOpenSourceProject
* Fixed policy assignment retrieval when Id is from other tenant, bogus or
null
FIXES [#3971](https://github.com/microsoft/Microsoft365DSC/issues/3971)
* Fixed compare logic for CIM instances in Test-TargetResource
* M365DSCRuleEvaluation
* Fix issue when it didn't find any matching resources and it tried to make a
comparison
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,14 @@ function Get-TargetResource
$nullResult.Ensure = 'Absent'
try
{
$getValue = $getValue = Get-MgBetaDeviceManagementDeviceConfiguration -DeviceConfigurationId $id -ErrorAction SilentlyContinue
if (-not [System.String]::IsNullOrEmpty($Id))
{
$getValue = Get-MgBetaDeviceManagementDeviceConfiguration -DeviceConfigurationId $id -ErrorAction SilentlyContinue
}
else
{
$getValue = $null
}

#region resource generator code
if ($null -eq $getValue)
Expand All @@ -149,11 +156,19 @@ function Get-TargetResource

if ($null -eq $getValue)
{
Write-Verbose -Message "Nothing with id {$id} was found"
if (-not [String]::IsNullOrEmpty($Id))
{
Write-Verbose -Message "Nothing with id {$Id} was found"
}
else
{
Write-Verbose -Message "Nothing with display name {$DisplayName} was found"
}

return $nullResult
}

Write-Verbose -Message "Found something with id {$id}"
Write-Verbose -Message "Found something with id {$($getValue.Id)}"
$results = @{

#region resource generator code
Expand Down Expand Up @@ -183,7 +198,7 @@ function Get-TargetResource
Managedidentity = $ManagedIdentity.IsPresent
}

$assignmentsValues = Get-MgBetaDeviceManagementDeviceConfigurationAssignment -DeviceConfigurationId $Id
$assignmentsValues = Get-MgBetaDeviceManagementDeviceConfigurationAssignment -DeviceConfigurationId $getValue.Id
$assignmentResult = @()
foreach ($assignmentEntry in $AssignmentsValues)
{
Expand Down Expand Up @@ -596,34 +611,19 @@ function Test-TargetResource
}
$testResult = $true

#Compare Cim instances
foreach ($key in $PSBoundParameters.Keys)
{
if ($PSBoundParameters[$key].getType().Name -like '*CimInstance*')
$source = $PSBoundParameters.$key
$target = $CurrentValues.$key
if ($source.getType().Name -like '*CimInstance*')
{
$CIMArraySource = @()
$CIMArrayTarget = @()
$CIMArraySource += $PSBoundParameters[$key]
$CIMArrayTarget += $CurrentValues.$key
if ($CIMArraySource.count -ne $CIMArrayTarget.count)
{
Write-Verbose -Message "Configuration drift:Number of items does not match: Source=$($CIMArraySource.count) Target=$($CIMArrayTarget.count)"
$testResult = $false
break
}
$i = 0
foreach ($item in $CIMArraySource )
{
$testResult = Compare-M365DSCComplexObject `
-Source (Get-M365DSCDRGComplexTypeToHashtable -ComplexObject $CIMArraySource[$i]) `
-Target ($CIMArrayTarget[$i])
$source = Get-M365DSCDRGComplexTypeToHashtable -ComplexObject $source

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

$i++
if (-Not $testResult)
{
$testResult = $false
break
}
}
if (-Not $testResult)
{
$testResult = $false
Expand Down
Loading