From 5d0d1ff883f7f08f7781968994e6701a215c9e41 Mon Sep 17 00:00:00 2001 From: dannyKBjj Date: Wed, 22 Jan 2025 16:23:38 +0000 Subject: [PATCH 1/3] Fix for issue #5594 AppId not being exported for MSFT_MicrosoftGGraphlistitem because case for .appId in the code was wrong (appid instead of appId). Corrected this. AppId now exports/test/sets/ etc. correctly for properties CompliantAppsList AppsVisibilityList AppsSingleAppModeList --- ...FT_IntuneDeviceConfigurationPolicyiOS.psm1 | 86 +++++++++---------- 1 file changed, 40 insertions(+), 46 deletions(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDeviceConfigurationPolicyiOS/MSFT_IntuneDeviceConfigurationPolicyiOS.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDeviceConfigurationPolicyiOS/MSFT_IntuneDeviceConfigurationPolicyiOS.psm1 index a22dcb910f..205ee4468b 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDeviceConfigurationPolicyiOS/MSFT_IntuneDeviceConfigurationPolicyiOS.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDeviceConfigurationPolicyiOS/MSFT_IntuneDeviceConfigurationPolicyiOS.psm1 @@ -810,55 +810,50 @@ function Get-TargetResource $AccessTokens ) - Write-Verbose -Message "Getting configuration of the Intune Device Configuration Policy for iOS with Id {$Id} and DisplayName {$DisplayName}" + try + { + $ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftGraph' ` + -InboundParameters $PSBoundParameters + } + catch + { + Write-Verbose -Message 'Connection to the workload failed.' + } + #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 + + $nullResult = $PSBoundParameters + $nullResult.Ensure = 'Absent' try { - if (-not $Script:exportedInstance) - { - $ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftGraph' ` - -InboundParameters $PSBoundParameters - - #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 - - $nullResult = $PSBoundParameters - $nullResult.Ensure = 'Absent' - - $getValue = $null - #region resource generator code - if (-not [string]::IsNullOrEmpty($Id)) - { - $getValue = Get-MgBetaDeviceManagementDeviceConfiguration -DeviceConfigurationId $Id -ErrorAction SilentlyContinue - } + $getValue = $null - if (-not $getValue) - { - $getValue = Get-MgBetaDeviceManagementDeviceConfiguration -All -Filter "DisplayName eq '$Displayname'" -ErrorAction SilentlyContinue | Where-Object ` - -FilterScript { ` - $_.AdditionalProperties.'@odata.type' -eq '#microsoft.graph.iosGeneralDeviceConfiguration' ` - } - } - #endregion + #region resource generator code + $getValue = Get-MgBetaDeviceManagementDeviceConfiguration -DeviceConfigurationId $id -ErrorAction SilentlyContinue - if ($null -eq $getValue) - { - Write-Verbose -Message "Nothing with id {$id} was found" - return $nullResult + if (-not $getValue) + { + $getValue = Get-MgBetaDeviceManagementDeviceConfiguration -All -Filter "DisplayName eq '$Displayname'" -ErrorAction SilentlyContinue | Where-Object ` + -FilterScript { ` + $_.AdditionalProperties.'@odata.type' -eq '#microsoft.graph.iosGeneralDeviceConfiguration' ` } } - else + #endregion + + if ($null -eq $getValue) { - $getValue = $Script:exportedInstance + Write-Verbose -Message "Nothing with id {$id} was found" + return $nullResult } Write-Verbose -Message "Found something with id {$id}" @@ -1058,7 +1053,7 @@ function Get-TargetResource foreach ($currentValue in $currentValueArray) { $currentHash = @{} - $currentHash.add('AppId', $currentValue.appid) + $currentHash.add('AppId', $currentValue.appId) $currentHash.add('Publisher', $currentValue.publisher) $currentHash.add('AppStoreUrl', $currentValue.appStoreUrl) $currentHash.add('Name', $currentValue.name) @@ -1075,7 +1070,7 @@ function Get-TargetResource foreach ($currentValue in $currentValueArray) { $currentHash = @{} - $currentHash.add('AppId', $currentValue.appid) + $currentHash.add('AppId', $currentValue.appId) $currentHash.add('Publisher', $currentValue.publisher) $currentHash.add('AppStoreUrl', $currentValue.appStoreUrl) $currentHash.add('Name', $currentValue.name) @@ -1092,7 +1087,7 @@ function Get-TargetResource foreach ($currentValue in $currentValueArray) { $currentHash = @{} - $currentHash.add('AppId', $currentValue.appid) + $currentHash.add('AppId', $currentValue.appId) $currentHash.add('Publisher', $currentValue.publisher) $currentHash.add('AppStoreUrl', $currentValue.appStoreUrl) $currentHash.add('Name', $currentValue.name) @@ -1149,7 +1144,7 @@ function Get-TargetResource foreach ($currentChildValue in $currentValueChildArray) { $currentHash = @{} - $currentHash.add('AppId', $currentValue.appid) + $currentHash.add('AppId', $currentValue.appId) $currentHash.add('Publisher', $currentValue.publisher) $currentHash.add('AppStoreUrl', $currentValue.appStoreUrl) $currentHash.add('Name', $currentValue.name) @@ -3091,7 +3086,6 @@ function Export-TargetResource AccessTokens = $AccessTokens } - $Script:exportedInstance = $config $Results = Get-TargetResource @Params $Results = Update-M365DSCExportAuthenticationResults -ConnectionMode $ConnectionMode ` -Results $Results From 8a5b3879456b6a5bec24511f6a704c58e8888494 Mon Sep 17 00:00:00 2001 From: dannyKBjj Date: Wed, 22 Jan 2025 16:35:09 +0000 Subject: [PATCH 2/3] Updated changelog.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ea6b11f8d..ff69902416 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,8 @@ * Fix values that have a zero length whitespace character. * IntuneAppProtectionPolicyiOS * Fixes [#5589] https://github.com/microsoft/Microsoft365DSC/issues/5589 +* IntuneDeviceConfigurationPolicyiOS + * Fixes [#5594] https://github.com/microsoft/Microsoft365DSC/issues/5594 * SCAutoSensitivityLabelPolicy * Use correct parameter `DesiredValues` given to `Test-M365DSCParameterState`, contrary to `EXOTenantAllowBlockListItems` these resources are not affected From 384669092baa47e74366bceed949bd70a495fe44 Mon Sep 17 00:00:00 2001 From: dannyKBjj Date: Sun, 26 Jan 2025 10:11:16 +0000 Subject: [PATCH 3/3] Update MSFT_IntuneDeviceConfigurationPolicyiOS.psm1 made edits requested in comments --- ...FT_IntuneDeviceConfigurationPolicyiOS.psm1 | 78 ++++++++++--------- 1 file changed, 42 insertions(+), 36 deletions(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDeviceConfigurationPolicyiOS/MSFT_IntuneDeviceConfigurationPolicyiOS.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDeviceConfigurationPolicyiOS/MSFT_IntuneDeviceConfigurationPolicyiOS.psm1 index 205ee4468b..bc91828072 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDeviceConfigurationPolicyiOS/MSFT_IntuneDeviceConfigurationPolicyiOS.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDeviceConfigurationPolicyiOS/MSFT_IntuneDeviceConfigurationPolicyiOS.psm1 @@ -810,50 +810,55 @@ function Get-TargetResource $AccessTokens ) - try - { - $ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftGraph' ` - -InboundParameters $PSBoundParameters - } - catch - { - Write-Verbose -Message 'Connection to the workload failed.' - } + Write-Verbose -Message "Getting configuration of the Intune Device Configuration Policy for iOS with Id {$Id} and DisplayName {$DisplayName}" - #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 - - $nullResult = $PSBoundParameters - $nullResult.Ensure = 'Absent' try { - $getValue = $null + if (-not $Script:exportedInstance) + { + $ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftGraph' ` + -InboundParameters $PSBoundParameters + + #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 + + $nullResult = $PSBoundParameters + $nullResult.Ensure = 'Absent' + + $getValue = $null + #region resource generator code + if (-not [string]::IsNullOrEmpty($Id)) + { + $getValue = Get-MgBetaDeviceManagementDeviceConfiguration -DeviceConfigurationId $Id -ErrorAction SilentlyContinue + } - #region resource generator code - $getValue = Get-MgBetaDeviceManagementDeviceConfiguration -DeviceConfigurationId $id -ErrorAction SilentlyContinue + if (-not $getValue) + { + $getValue = Get-MgBetaDeviceManagementDeviceConfiguration -All -Filter "DisplayName eq '$Displayname'" -ErrorAction SilentlyContinue | Where-Object ` + -FilterScript { ` + $_.AdditionalProperties.'@odata.type' -eq '#microsoft.graph.iosGeneralDeviceConfiguration' ` + } + } + #endregion - if (-not $getValue) - { - $getValue = Get-MgBetaDeviceManagementDeviceConfiguration -All -Filter "DisplayName eq '$Displayname'" -ErrorAction SilentlyContinue | Where-Object ` - -FilterScript { ` - $_.AdditionalProperties.'@odata.type' -eq '#microsoft.graph.iosGeneralDeviceConfiguration' ` + if ($null -eq $getValue) + { + Write-Verbose -Message "Nothing with id {$id} was found" + return $nullResult } } - #endregion - - if ($null -eq $getValue) + else { - Write-Verbose -Message "Nothing with id {$id} was found" - return $nullResult + $getValue = $Script:exportedInstance } Write-Verbose -Message "Found something with id {$id}" @@ -3086,6 +3091,7 @@ function Export-TargetResource AccessTokens = $AccessTokens } + $Script:exportedInstance = $config $Results = Get-TargetResource @Params $Results = Update-M365DSCExportAuthenticationResults -ConnectionMode $ConnectionMode ` -Results $Results