Skip to content

Commit

Permalink
Merge pull request #4307 from ricmestre/fix3972
Browse files Browse the repository at this point in the history
IntuneDeviceConfigurationPolicyAndroidWorkProfile: Fix typo that makes it export incorrectly and not reporting the correct state of resource
  • Loading branch information
NikCharlebois authored Feb 14, 2024
2 parents cff51f9 + d698de7 commit 95777b8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
* EXOMobileDeviceMailboxPolicy
* Fixes an issue where an empty MinPasswordLength value was always passed down
to the update logic flow.
* IntuneDeviceConfigurationPolicyAndroidWorkProfile
* Fix typo in variable which made it export incorrectly and report that
resource was not in correct state due to testing an incorrect value
FIXES [#3972](https://github.com/microsoft/Microsoft365DSC/issues/3972)
* DEPENDENCIES
* Updated DSCParser to version 1.4.0.2.
* Updated Microsoft.Graph dependencies to version 2.13.1.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ function Get-TargetResource
RequiredPasswordComplexity = $policy.AdditionalProperties.requiredPasswordComplexity
WorkProfileAllowAppInstallsFromUnknownSources = $policy.AdditionalProperties.workProfileAllowAppInstallsFromUnknownSources
WorkProfileDataSharingType = $policy.AdditionalProperties.workProfileDataSharingType
WorkProfileBlockNotificationsWhileDeviceLocked = $policy.AdditionalProperties.WorkProfileBlockNotificationsWhileDeviceLocked
WorkProfileBlockNotificationsWhileDeviceLocked = $policy.AdditionalProperties.workProfileBlockNotificationsWhileDeviceLocked
WorkProfileBlockAddingAccounts = $policy.AdditionalProperties.workProfileBlockAddingAccounts
WorkProfileBluetoothEnableContactSharing = $policy.AdditionalProperties.workProfileBluetoothEnableContactSharing
WorkProfileBlockScreenCapture = $policy.AdditionalProperties.workProfileBlockScreenCapture
Expand Down Expand Up @@ -644,8 +644,8 @@ function Set-TargetResource
{
Write-Verbose -Message "Updating existing Device Configuration Policy {$DisplayName}"
$configDevicePolicy = Get-MgBetaDeviceManagementDeviceConfiguration -Filter "DisplayName eq '$Displayname'" -ErrorAction SilentlyContinue | Where-Object `
-FilterScript { `
$_.AdditionalProperties.'@odata.type' -eq '#microsoft.graph.androidWorkProfileGeneralDeviceConfiguration' `
-FilterScript {
$_.AdditionalProperties.'@odata.type' -eq '#microsoft.graph.androidWorkProfileGeneralDeviceConfiguration'
}

$PSBoundParameters.Remove('DisplayName') | Out-Null
Expand Down Expand Up @@ -673,7 +673,7 @@ function Set-TargetResource
{
Write-Verbose -Message "Removing Device Configuration Policy {$DisplayName}"
$configDevicePolicy = Get-MgBetaDeviceManagementDeviceConfiguration -Filter "DisplayName eq '$Displayname'" -ErrorAction SilentlyContinue | Where-Object `
-FilterScript { `
-FilterScript {
$_.AdditionalProperties.'@odata.type' -eq '#microsoft.graph.androidWorkProfileGeneralDeviceConfiguration' `
}

Expand Down Expand Up @@ -929,24 +929,17 @@ function Test-TargetResource
Write-Verbose -Message "Testing configuration of Device Configuration Policy {$DisplayName}"

$CurrentValues = Get-TargetResource @PSBoundParameters

Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)"
Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $PSBoundParameters)"

$ValuesToCheck = $PSBoundParameters
$ValuesToCheck.Remove('Credential') | Out-Null
$ValuesToCheck.Remove('ApplicationId') | Out-Null
$ValuesToCheck.Remove('TenantId') | Out-Null
$ValuesToCheck.Remove('ApplicationSecret') | Out-Null
$ValuesToCheck = ([Hashtable]$PSBoundParameters).clone()
$ValuesToCheck = Remove-M365DSCAuthenticationParameter -BoundParameters $ValuesToCheck

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

#region Assignments
if ((-not $CurrentValues.Assignments) -xor (-not $ValuesToCheck.Assignments))
{
Write-Verbose -Message 'Configuration drift: one the assignment is null'
Expand Down Expand Up @@ -1004,10 +997,16 @@ function Test-TargetResource
$ValuesToCheck.Remove('Assignments') | Out-Null
#endregion

$TestResult = Test-M365DSCParameterState -CurrentValues $CurrentValues `
-Source $($MyInvocation.MyCommand.Source) `
-DesiredValues $PSBoundParameters `
-ValuesToCheck $ValuesToCheck.Keys
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
}

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

Expand Down

0 comments on commit 95777b8

Please sign in to comment.