From bcf30cda83dd40d88bb0bc6ce652b24fdd7a93c2 Mon Sep 17 00:00:00 2001 From: dannyKBjj Date: Tue, 12 Nov 2024 17:02:38 +0000 Subject: [PATCH 01/14] First draft of module Untested --- ...IntuneMobileAppConfigurationPolicyIOS.psm1 | 775 ++++++++++++++++++ ...MobileAppConfigurationPolicyIOS.schema.mof | Bin 0 -> 8196 bytes .../readme.md | 6 + .../settings.json | 32 + 4 files changed, 813 insertions(+) create mode 100644 Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 create mode 100644 Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.schema.mof create mode 100644 Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/readme.md create mode 100644 Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/settings.json diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 new file mode 100644 index 0000000000..039b5b9077 --- /dev/null +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 @@ -0,0 +1,775 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + #region resource generator code + [Parameter()] + [System.String] + $Id, + + [Parameter(Mandatory = $true)] + [System.String] + $DisplayName, + + [Parameter()] + [System.String] + $Description, + + [Parameter()] + [System.String[]] + $targetedMobileApps, + + [Parameter()] + [Microsoft.Management.Infrastructure.CimInstance[]] + $settings, + + + #====================== + #standard params + [Parameter()] + [Microsoft.Management.Infrastructure.CimInstance[]] + $Assignments, + #endregion + + [Parameter()] + [System.String] + [ValidateSet('Absent', 'Present')] + $Ensure = 'Present', + + [Parameter()] + [System.Management.Automation.PSCredential] + $Credential, + + [Parameter()] + [System.String] + $ApplicationId, + + [Parameter()] + [System.String] + $TenantId, + + [Parameter()] + [System.Management.Automation.PSCredential] + $ApplicationSecret, + + [Parameter()] + [System.String] + $CertificateThumbprint, + + [Parameter()] + [Switch] + $ManagedIdentity, + + [Parameter()] + [System.String[]] + $AccessTokens + + ) + + 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 + { + #$getValue = Get-MgBetaDeviceManagementDeviceConfiguration -DeviceConfigurationId $id -ErrorAction SilentlyContinue + if (-not [string]::IsNullOrWhiteSpace($id)){ $getValue = Get-MgBetaDeviceAppManagementMobileAppConfiguration -DeviceConfigurationId $id -ErrorAction SilentlyContinue } + + #region resource generator code + if ($null -eq $getValue) + { + $getValue = Get-MgBetaDeviceAppManagementMobileAppConfiguration -Filter "DisplayName eq '$Displayname'" -ErrorAction SilentlyContinue | Where-Object ` + -FilterScript { ` + $_.AdditionalProperties.'@odata.type' -eq '#microsoft.graph.iosMobileAppConfiguration' ` + } + } + #endregion + + if ($null -eq $getValue) + { + Write-Verbose -Message "Nothing with id {$id} was found" + return $nullResult + } + + Write-Verbose -Message "Found something with id {$id}" + +<# + $complexSettings = @() + foreach ($setting in $getValue.AdditionalProperties.settings) + { + $mySettings = @{} + $mySettings.Add($setting.keys, $setting.values) + + if ($mySettings.values.Where({$null -ne $_}).count -gt 0) + { + $complexSettings += $mySettings + } + } + +#> + + + + + + + + + $results = @{ + #region resource generator code + Id = $getValue.Id + Description = $getValue.Description + DisplayName = $getValue.DisplayName + + targetedMobileApps = $getValue.TargetedMobileApps + settings = $getValue.AdditionalProperties.settings + encodedSettingXml = $getValue.AdditionalProperties.encodedSettingXml + + Ensure = 'Present' + Credential = $Credential + ApplicationId = $ApplicationId + TenantId = $TenantId + ApplicationSecret = $ApplicationSecret + CertificateThumbprint = $CertificateThumbprint + Managedidentity = $ManagedIdentity.IsPresent + AccessTokens = $AccessTokens + version = $getValue.AdditionalProperties.version + + } + + + + $assignmentsValues = Get-MgBetaDeviceAppManagementMobileAppConfigurationAssignment -ManagedDeviceMobileAppConfigurationId $Results.Id + $assignmentResult = @() + if ($assignmentsValues.Count -gt 0) + { + $assignmentResult += ConvertFrom-IntunePolicyAssignment ` + -IncludeDeviceFilter:$true ` + -Assignments ($assignmentsValues) + } + $results.Add('Assignments', $assignmentResult) + + return [System.Collections.Hashtable] $results + } + catch + { + New-M365DSCLogEntry -Message 'Error retrieving data:' ` + -Exception $_ ` + -Source $($MyInvocation.MyCommand.Source) ` + -TenantId $TenantId ` + -Credential $Credential + + return $nullResult + } +} + +function Set-TargetResource +{ + [CmdletBinding()] + param + ( + #region resource generator code + [Parameter()] + [System.String] + $Id, + + [Parameter(Mandatory = $true)] + [System.String] + $DisplayName, + + [Parameter()] + [System.String] + $Description, + + [Parameter()] + [System.String[]] + $targetedMobileApps, + + [Parameter()] + [Microsoft.Management.Infrastructure.CimInstance[]] + $settings, + + + #====================== + #standard params + [Parameter()] + [Microsoft.Management.Infrastructure.CimInstance[]] + $Assignments, + #endregion + + [Parameter()] + [System.String] + [ValidateSet('Absent', 'Present')] + $Ensure = 'Present', + + [Parameter()] + [System.Management.Automation.PSCredential] + $Credential, + + [Parameter()] + [System.String] + $ApplicationId, + + [Parameter()] + [System.String] + $TenantId, + + [Parameter()] + [System.Management.Automation.PSCredential] + $ApplicationSecret, + + [Parameter()] + [System.String] + $CertificateThumbprint, + + [Parameter()] + [Switch] + $ManagedIdentity, + + [Parameter()] + [System.String[]] + $AccessTokens + ) + + try + { + $ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftGraph' ` + -InboundParameters $PSBoundParameters + } + catch + { + Write-Verbose -Message $_ + } + + #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 + + $currentInstance = Get-TargetResource @PSBoundParameters + + $PSBoundParameters.Remove('Ensure') | Out-Null + $PSBoundParameters.Remove('Credential') | Out-Null + $PSBoundParameters.Remove('ApplicationId') | Out-Null + $PSBoundParameters.Remove('ApplicationSecret') | Out-Null + $PSBoundParameters.Remove('TenantId') | Out-Null + $PSBoundParameters.Remove('CertificateThumbprint') | Out-Null + $PSBoundParameters.Remove('ManagedIdentity') | Out-Null + $PSBoundParameters.Remove('AccessTokens') | Out-Null + + + + + if ($Ensure -eq 'Present' -and $currentInstance.Ensure -eq 'Absent') + { + Write-Verbose -Message "Creating {$DisplayName}" + $PSBoundParameters.Remove('Assignments') | Out-Null + + $CreateParameters = ([Hashtable]$PSBoundParameters).clone() + $CreateParameters = Rename-M365DSCCimInstanceParameter -Properties $CreateParameters + + $AdditionalProperties = Get-M365DSCAdditionalProperties -Properties ($CreateParameters) + + foreach ($key in $AdditionalProperties.keys) + { + if ($key -ne '@odata.type') + { + $keyName = $key.substring(0, 1).ToUpper() + $key.substring(1, $key.length - 1) + $CreateParameters.remove($keyName) + } + } + + $CreateParameters.Remove('Id') | Out-Null + $CreateParameters.Remove('Verbose') | Out-Null + + foreach ($key in ($CreateParameters.clone()).Keys) + { + if ($CreateParameters[$key].getType().Fullname -like '*CimInstance*') + { + $CreateParameters[$key] = Convert-M365DSCDRGComplexTypeToHashtable -ComplexObject $CreateParameters[$key] + } + } + + + + $CreateParameters.add('AdditionalProperties', $AdditionalProperties) + + #region resource generator code + $policy = New-MgBetaDeviceManagementDeviceConfiguration @CreateParameters + $assignmentsHash = ConvertTo-IntunePolicyAssignment -IncludeDeviceFilter:$true -Assignments $Assignments + + if ($policy.id) + { + Update-DeviceConfigurationPolicyAssignment -DeviceConfigurationPolicyId $policy.id ` + -Targets $assignmentsHash ` + -Repository 'deviceAppManagement/mobileAppConfigurations' + } + #endregion + } + elseif ($Ensure -eq 'Present' -and $currentInstance.Ensure -eq 'Present') + { + Write-Verbose -Message "Updating {$DisplayName}" + $PSBoundParameters.Remove('Assignments') | Out-Null + + $UpdateParameters = ([Hashtable]$PSBoundParameters).clone() + $UpdateParameters = Rename-M365DSCCimInstanceParameter -Properties $UpdateParameters + + $AdditionalProperties = Get-M365DSCAdditionalProperties -Properties ($UpdateParameters) + foreach ($key in $AdditionalProperties.keys) + { + if ($key -ne '@odata.type') + { + $keyName = $key.substring(0, 1).ToUpper() + $key.substring(1, $key.length - 1) + $UpdateParameters.remove($keyName) + } + } + + $UpdateParameters.Remove('Id') | Out-Null + $UpdateParameters.Remove('Verbose') | Out-Null + + foreach ($key in ($UpdateParameters.clone()).Keys) + { + if ($UpdateParameters[$key].getType().Fullname -like '*CimInstance*') + { + $UpdateParameters[$key] = Convert-M365DSCDRGComplexTypeToHashtable -ComplexObject $UpdateParameters[$key] + } + } + + + + #region resource generator code + Update-MgBetaDeviceManagementDeviceConfiguration @UpdateParameters ` + -DeviceConfigurationId $currentInstance.Id + $assignmentsHash = ConvertTo-IntunePolicyAssignment -IncludeDeviceFilter:$true -Assignments $Assignments + Update-DeviceConfigurationPolicyAssignment -DeviceConfigurationPolicyId $currentInstance.id ` + -Targets $assignmentsHash ` + -Repository 'deviceAppManagement/mobileAppConfigurations' + #endregion + } + elseif ($Ensure -eq 'Absent' -and $currentInstance.Ensure -eq 'Present') + { + Write-Verbose -Message "Removing {$DisplayName}" + #region resource generator code + Remove-MgBetaDeviceManagementDeviceConfiguration -DeviceConfigurationId $currentInstance.Id + #endregion + } +} + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + #region resource generator code + [Parameter()] + [System.String] + $Id, + + [Parameter(Mandatory = $true)] + [System.String] + $DisplayName, + + [Parameter()] + [System.String] + $Description, + + [Parameter()] + [System.String[]] + $targetedMobileApps, + + [Parameter()] + [Microsoft.Management.Infrastructure.CimInstance[]] + $settings, + + + #====================== + #standard params + [Parameter()] + [Microsoft.Management.Infrastructure.CimInstance[]] + $Assignments, + #endregion + + [Parameter()] + [System.String] + [ValidateSet('Absent', 'Present')] + $Ensure = 'Present', + + [Parameter()] + [System.Management.Automation.PSCredential] + $Credential, + + [Parameter()] + [System.String] + $ApplicationId, + + [Parameter()] + [System.String] + $TenantId, + + [Parameter()] + [System.Management.Automation.PSCredential] + $ApplicationSecret, + + [Parameter()] + [System.String] + $CertificateThumbprint, + + [Parameter()] + [Switch] + $ManagedIdentity, + + [Parameter()] + [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 {$id}" + + $CurrentValues = Get-TargetResource @PSBoundParameters + $ValuesToCheck = ([Hashtable]$PSBoundParameters).clone() + + if ($CurrentValues.Ensure -ne $Ensure) + { + Write-Verbose -Message "Test-TargetResource returned $false" + return $false + } + $testResult = $true + + foreach ($key in $PSBoundParameters.Keys) + { + if ($PSBoundParameters[$key].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]) + + $i++ + if (-Not $testResult) + { + $testResult = $false + break + } + } + if (-Not $testResult) + { + $testResult = $false + break + } + + $ValuesToCheck.Remove($key) | 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)" + + #Convert any DateTime to String + foreach ($key in $ValuesToCheck.Keys) + { + if (($null -ne $CurrentValues[$key]) ` + -and ($CurrentValues[$key].getType().Name -eq 'DateTime')) + { + $CurrentValues[$key] = $CurrentValues[$key].toString() + } + } + + if ($testResult) + { + $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck $ValuesToCheck.Keys + } + + Write-Verbose -Message "Test-TargetResource returned $testResult" + + return $testResult +} + +function Export-TargetResource +{ + [CmdletBinding()] + [OutputType([System.String])] + param + ( + [Parameter()] + [System.String] + $Filter, + + [Parameter()] + [System.Management.Automation.PSCredential] + $Credential, + + [Parameter()] + [System.String] + $ApplicationId, + + [Parameter()] + [System.String] + $TenantId, + + [Parameter()] + [System.Management.Automation.PSCredential] + $ApplicationSecret, + + [Parameter()] + [System.String] + $CertificateThumbprint, + + [Parameter()] + [Switch] + $ManagedIdentity, + + [Parameter()] + [System.String[]] + $AccessTokens + ) + + $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 + + try + { + + #region resource generator code + [array]$getValue = Get-MgBetaDeviceManagementDeviceConfiguration -Filter $Filter -All ` + -ErrorAction Stop | Where-Object ` + -FilterScript { ` + $_.AdditionalProperties.'@odata.type' -eq '#microsoft.graph.iosMobileAppConfiguration' ` + } + #endregion + + $i = 1 + $dscContent = '' + if ($getValue.Length -eq 0) + { + Write-Host $Global:M365DSCEmojiGreenCheckMark + } + else + { + Write-Host "`r`n" -NoNewline + } + foreach ($config in $getValue) + { + if ($null -ne $Global:M365DSCExportResourceInstancesCount) + { + $Global:M365DSCExportResourceInstancesCount++ + } + + Write-Host " |---[$i/$($getValue.Count)] $($config.DisplayName)" -NoNewline + $params = @{ + Id = $config.id + DisplayName = $config.DisplayName + Ensure = 'Present' + Credential = $Credential + ApplicationId = $ApplicationId + TenantId = $TenantId + ApplicationSecret = $ApplicationSecret + CertificateThumbprint = $CertificateThumbprint + Managedidentity = $ManagedIdentity.IsPresent + AccessTokens = $AccessTokens + } + + $Results = Get-TargetResource @Params + $Results = Update-M365DSCExportAuthenticationResults -ConnectionMode $ConnectionMode ` + -Results $Results + + if ($Results.Assignments) + { + $complexTypeStringResult = Get-M365DSCDRGComplexTypeToString -ComplexObject $Results.Assignments -CIMInstanceName DeviceManagementConfigurationPolicyAssignments + if ($complexTypeStringResult) + { + $Results.Assignments = $complexTypeStringResult + } + else + { + $Results.Remove('Assignments') | Out-Null + } + } + + + + + + + + + + + + $currentDSCBlock = Get-M365DSCExportContentForResource -ResourceName $ResourceName ` + -ConnectionMode $ConnectionMode ` + -ModulePath $PSScriptRoot ` + -Results $Results ` + -Credential $Credential + + + + + if ($Results.Assignments) + { + $isCIMArray = $false + if ($Results.Assignments.getType().Fullname -like '*[[\]]') + { + $isCIMArray = $true + } + $currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock -ParameterName 'Assignments' -IsCIMArray:$isCIMArray + } + + $dscContent += $currentDSCBlock + Save-M365DSCPartialExport -Content $currentDSCBlock ` + -FileName $Global:PartialExportFileName + $i++ + Write-Host $Global:M365DSCEmojiGreenCheckMark + } + return $dscContent + } + catch + { + if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or ` + $_.Exception -like "*Request not applicable to target tenant*") + { + Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune." + } + else + { + Write-Host $Global:M365DSCEmojiRedX + + New-M365DSCLogEntry -Message 'Error during Export:' ` + -Exception $_ ` + -Source $($MyInvocation.MyCommand.Source) ` + -TenantId $TenantId ` + -Credential $Credential + } + + return '' + } +} + + + +function Get-M365DSCAdditionalProperties +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [Parameter(Mandatory = 'true')] + [System.Collections.Hashtable] + $Properties + ) + + $additionalProperties = @( + 'encodedSettingXml' + 'settings' + ) + + $results = @{'@odata.type' = '#microsoft.graph.iosMobileAppConfiguration' } + $cloneProperties = $Properties.clone() + foreach ($property in $cloneProperties.Keys) + { + if ($property -in ($additionalProperties) ) + { + $propertyName = $property[0].ToString().ToLower() + $property.Substring(1, $property.Length - 1) + if ($properties.$property -and $properties.$property.getType().FullName -like '*CIMInstance*') + { + if ($properties.$property.getType().FullName -like '*[[\]]') + { + $array = @() + foreach ($item in $properties.$property) + { + $array += Convert-M365DSCDRGComplexTypeToHashtable -ComplexObject $item + } + $propertyValue = $array + } + else + { + $propertyValue = Convert-M365DSCDRGComplexTypeToHashtable -ComplexObject $properties.$property + } + + } + else + { + $propertyValue = $properties.$property + } + + $results.Add($propertyName, $propertyValue) + } + } + if ($results.Count -eq 1) + { + return $null + } + return $results +} + +Export-ModuleMember -Function *-TargetResource diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.schema.mof b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.schema.mof new file mode 100644 index 0000000000000000000000000000000000000000..1d1beae36f3a81365f7acf7e64c3939bea299147 GIT binary patch literal 8196 zcmeHMTW=ai6h6o*rlJA?t zFf+?6u)DaGstB#YdpUEi-}&b3*Dq&sAOq=0hR-|c$pqhh8Oczd$gcb-`|@mY?8=^; z%Oly5tHm=$T5>AK(v}N3#Pc8V^cB8akU7M0gWtC}hBC!UlzWXkZe)g)Iyk3mo#4vA zK6xh%s|)WLE}qQns`vJ<5&fLWpODdqjGjEjIj){zZJrx1B-4tve84q>b9cDHUn6M2 z|K0fxo}#8xoK;`M>+eI#o?Yb~t`DHSS~!+_T=@Zd(&`E1W>)qTKD)vH9jy0Z{(FR{ z#!2hixX-P>i&Zv}NG%5P+OA9QX3(fBZ|yf@nDS!vb;8JQPj*lKwwW}8zM2QWSs!lG zPgjUXI_JU+o!H!@M|;r7W#xJwe$M4Y_B|iqLDqVeT>C%d!#NP-6!sH^hQI)WswB>J z;1NZi7h6U#;^_b@5WCAGo59ojcy=Gp9xdvzi!+o(iA~r+yr01my^mA6_iuB0ooikwtLeV=Q+m42X&tU6{lGcs*+ z%mRx0{;~)Bird!z&}uwJU3GvLMt;XPbLro-Db~ShP&Z2K#Q6@p{dhfzSZ2$zuszG( zmZO-`$j9^ZJTJ>L z4{*|TyZ3t14fvkHIxT2yS)!5uMij#B}8rs^(UJA2%-L!Aw<)lU(MqUrJ7 zBdVerz0ZAadWI19M1vT(zFb$MSaRKN+W`OJG-3#A#_;;cPGrci$&2{CY+s%?(hF{m zV^-uC(U}q86va(qxXQI%_ZGiyEr#k8sGFM)jj(&*&ZReJ&&9c%?oR1gRb?sh>?`jP z`ptW!xTCK3NGPe;VxPUUdH4EReu6(gT2H%aiQ3AV^0~a}Ow2K2WxXR*XCJX*PhtcW zm)BeKkn!c7*-gc$RSUTsXG|t%m`7HP_$K^_80HxnnS^q(Y|fd88Ar(SOY1krwreYb zeU|Kjm`CLHGt%Xbw+RPy6%h7s@|{q-dfsTEI$Mj#uV#%7-Ji=Zc!Dt@8ctR)NpdDu zje02Nx$oh>!90r9a`^;n6W4U|#K{8Zq4X=y`rTjHA9Vh}-Qg4m!y6I5v)|i)HZpJd@9a}qrmd2b-|v^&fz^8`Y^RiriVv?pVxKe@>O#P zZ5;llrYyxs8uFk9yhZGc-z>P=I)xQ}YL~vZ4&EGCpRxkD8zI^bpiREh#J=<0oLZLm zTWU>bZ=5-)JF8|;im5f^pLs?LcN7 z>xk5RucdFsVy0UzqV=uZZuW1I7oqi4YoU#7oLPoIOl7BJl5_bE!58rFECf(kJ pRpgMH)2XWZ6Z;qkb|S?yohVh;JD4ckDd; Date: Tue, 12 Nov 2024 17:19:21 +0000 Subject: [PATCH 02/14] Update MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 --- .../MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 index 039b5b9077..e978d3d975 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 @@ -95,8 +95,7 @@ function Get-TargetResource $nullResult.Ensure = 'Absent' try { - #$getValue = Get-MgBetaDeviceManagementDeviceConfiguration -DeviceConfigurationId $id -ErrorAction SilentlyContinue - if (-not [string]::IsNullOrWhiteSpace($id)){ $getValue = Get-MgBetaDeviceAppManagementMobileAppConfiguration -DeviceConfigurationId $id -ErrorAction SilentlyContinue } + if (-not [string]::IsNullOrWhiteSpace($id)){ $getValue = Get-MgBetaDeviceAppManagementMobileAppConfiguration -ManagedDeviceMobileAppConfigurationId $id -ErrorAction SilentlyContinue } #region resource generator code if ($null -eq $getValue) @@ -325,7 +324,7 @@ function Set-TargetResource $CreateParameters.add('AdditionalProperties', $AdditionalProperties) #region resource generator code - $policy = New-MgBetaDeviceManagementDeviceConfiguration @CreateParameters + $policy = New-MgBetaDeviceAppManagementMobileAppConfiguration @CreateParameters $assignmentsHash = ConvertTo-IntunePolicyAssignment -IncludeDeviceFilter:$true -Assignments $Assignments if ($policy.id) @@ -368,8 +367,8 @@ function Set-TargetResource #region resource generator code - Update-MgBetaDeviceManagementDeviceConfiguration @UpdateParameters ` - -DeviceConfigurationId $currentInstance.Id + Update-MgBetaDeviceAppManagementMobileAppConfiguration @UpdateParameters ` + -ManagedDeviceMobileAppConfigurationId $currentInstance.Id $assignmentsHash = ConvertTo-IntunePolicyAssignment -IncludeDeviceFilter:$true -Assignments $Assignments Update-DeviceConfigurationPolicyAssignment -DeviceConfigurationPolicyId $currentInstance.id ` -Targets $assignmentsHash ` @@ -380,7 +379,7 @@ function Set-TargetResource { Write-Verbose -Message "Removing {$DisplayName}" #region resource generator code - Remove-MgBetaDeviceManagementDeviceConfiguration -DeviceConfigurationId $currentInstance.Id + Remove-MgBetaDeviceAppManagementMobileAppConfiguration -ManagedDeviceMobileAppConfigurationId $currentInstance.Id #endregion } } @@ -601,7 +600,7 @@ function Export-TargetResource { #region resource generator code - [array]$getValue = Get-MgBetaDeviceManagementDeviceConfiguration -Filter $Filter -All ` + [array]$getValue = Get-MgBetaDeviceAppManagementMobileAppConfiguration -Filter $Filter -All ` -ErrorAction Stop | Where-Object ` -FilterScript { ` $_.AdditionalProperties.'@odata.type' -eq '#microsoft.graph.iosMobileAppConfiguration' ` From 003d3a024bef882f62e1c2b595dcf7b1cf9b6d7f Mon Sep 17 00:00:00 2001 From: dannyKBjj Date: Tue, 12 Nov 2024 17:27:31 +0000 Subject: [PATCH 03/14] Updated .md and .json --- .../readme.md | 4 ++-- .../settings.json | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/readme.md b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/readme.md index a82c357af2..d18bcd36ae 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/readme.md +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/readme.md @@ -1,6 +1,6 @@ -# IntuneVPNConfigurationPolicyIOS +# IntuneMobileAppConfigurationPolicyIOS ## Description -This resource configures an Intune VPN Configuration Policy for iOS Device. +This resource configures an Intune Managed Device Mobile App Configuration Policy for iOS Device. diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/settings.json b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/settings.json index 994cfaa911..ebd0a5e8d5 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/settings.json +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/settings.json @@ -1,29 +1,29 @@ { - "resourceName": "IntuneVPNConfigurationPolicyIOS", - "description": "This resource configures an Intune VPN Configuration Policy for iOS Device.", + "resourceName": "IntuneMobileAppConfigurationPolicyIOS", + "description": "This resource configures an Intune Managed Device Mobile App Configuration Policy for iOS Device.", "permissions": { "graph": { "delegated": { "read": [ { - "name": "DeviceManagementConfiguration.Read.All" + "name": "DeviceManagementApps.Read.All" } ], "update": [ { - "name": "DeviceManagementConfiguration.ReadWrite.All" + "name": "DeviceManagementApps.ReadWrite.All" } ] }, "application": { "read": [ { - "name": "DeviceManagementConfiguration.Read.All" + "name": "DeviceManagementApps.Read.All" } ], "update": [ { - "name": "DeviceManagementConfiguration.ReadWrite.All" + "name": "DeviceManagementApps.ReadWrite.All" } ] } From cbb52db5db9e8d523fa78afcdab5a0adcece7c78 Mon Sep 17 00:00:00 2001 From: dannyKBjj Date: Tue, 12 Nov 2024 17:48:04 +0000 Subject: [PATCH 04/14] Update MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 --- .../MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 index e978d3d975..4885274866 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 @@ -115,7 +115,7 @@ function Get-TargetResource Write-Verbose -Message "Found something with id {$id}" -<# + $complexSettings = @() foreach ($setting in $getValue.AdditionalProperties.settings) { @@ -128,7 +128,7 @@ function Get-TargetResource } } -#> + @@ -144,7 +144,7 @@ function Get-TargetResource DisplayName = $getValue.DisplayName targetedMobileApps = $getValue.TargetedMobileApps - settings = $getValue.AdditionalProperties.settings + settings = $complexSettings #$getValue.AdditionalProperties.settings encodedSettingXml = $getValue.AdditionalProperties.encodedSettingXml Ensure = 'Present' From 152d3335cdadf565616465f96342bbc931811d2e Mon Sep 17 00:00:00 2001 From: dannyKBjj Date: Wed, 13 Nov 2024 11:14:26 +0000 Subject: [PATCH 05/14] Export Done Export appears to be working for "settings" --- ...IntuneMobileAppConfigurationPolicyIOS.psm1 | 40 ++++++++++++++----- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 index 4885274866..06616b468c 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 @@ -115,25 +115,21 @@ function Get-TargetResource Write-Verbose -Message "Found something with id {$id}" - + #need to convert dictionary object into a hashtable array so we can work with it $complexSettings = @() foreach ($setting in $getValue.AdditionalProperties.settings) { $mySettings = @{} - $mySettings.Add($setting.keys, $setting.values) - + $mySettings.Add('appConfigKey', $setting['appConfigKey']) + $mySettings.Add('appConfigKeyType', $setting['appConfigKeyType']) + $mySettings.Add('appConfigKeyValue', $setting['appConfigKeyValue']) + if ($mySettings.values.Where({$null -ne $_}).count -gt 0) { $complexSettings += $mySettings } } - - - - - - @@ -657,6 +653,20 @@ function Export-TargetResource + if ($null -ne $Results.settings) + { + $complexTypeStringResult = Get-M365DSCDRGComplexTypeToString ` + -ComplexObject $Results.settings ` + -CIMInstanceName 'MSFT_appConfigurationSettingItem' + if (-Not [String]::IsNullOrWhiteSpace($complexTypeStringResult)) + { + $Results.settings = $complexTypeStringResult + } + else + { + $Results.Remove('settings') | Out-Null + } + } @@ -684,6 +694,18 @@ function Export-TargetResource $currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock -ParameterName 'Assignments' -IsCIMArray:$isCIMArray } + + if ($Results.settings) + { + $isCIMArray = $false + if ($Results.settings.getType().Fullname -like '*[[\]]') + { + $isCIMArray = $true + } + $currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock -ParameterName 'settings' -IsCIMArray:$isCIMArray + } + + $dscContent += $currentDSCBlock Save-M365DSCPartialExport -Content $currentDSCBlock ` -FileName $Global:PartialExportFileName From 2abf667ab20df888de3a3fb90af16daaae9b7d37 Mon Sep 17 00:00:00 2001 From: dannyKBjj Date: Wed, 13 Nov 2024 17:11:31 +0000 Subject: [PATCH 06/14] Tested OK Module is affected by issue #5396. Replace ` with " in M365TenantConfig.ps1 is your configuration key values contain double quotes. Otherwise, it should work as expected. --- ...IntuneMobileAppConfigurationPolicyIOS.psm1 | 14 ++++++++++++-- ...MobileAppConfigurationPolicyIOS.schema.mof | Bin 8196 -> 7984 bytes 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 index 06616b468c..7349c643b8 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 @@ -25,6 +25,9 @@ function Get-TargetResource [Microsoft.Management.Infrastructure.CimInstance[]] $settings, + [Parameter()] + [System.String] + $encodedSettingXml, #====================== #standard params @@ -207,6 +210,9 @@ function Set-TargetResource [Microsoft.Management.Infrastructure.CimInstance[]] $settings, + [Parameter()] + [System.String] + $encodedSettingXml, #====================== #standard params @@ -282,7 +288,7 @@ function Set-TargetResource $PSBoundParameters.Remove('ManagedIdentity') | Out-Null $PSBoundParameters.Remove('AccessTokens') | Out-Null - + if ($Ensure -eq 'Present' -and $currentInstance.Ensure -eq 'Absent') @@ -359,7 +365,7 @@ function Set-TargetResource $UpdateParameters[$key] = Convert-M365DSCDRGComplexTypeToHashtable -ComplexObject $UpdateParameters[$key] } } - + $UpdateParameters.add('AdditionalProperties', $AdditionalProperties) #region resource generator code @@ -407,6 +413,9 @@ function Test-TargetResource [Microsoft.Management.Infrastructure.CimInstance[]] $settings, + [Parameter()] + [System.String] + $encodedSettingXml, #====================== #standard params @@ -712,6 +721,7 @@ function Export-TargetResource $i++ Write-Host $Global:M365DSCEmojiGreenCheckMark } + return $dscContent } catch diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.schema.mof b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.schema.mof index 1d1beae36f3a81365f7acf7e64c3939bea299147..d09774961eca88ea67455f618794f1c369cb29e0 100644 GIT binary patch delta 33 jcmZp1*kHF|7yslcA)U#$`0b#y&}J`zKBmn_gdKPQppj-6Ln=cNLoq`p zLq0rdl)bGH^})C~Ur2O_+-Z0P`d!C;$Ke From 5fed672b464e50d16a351c0d37e7c4718d9a479b Mon Sep 17 00:00:00 2001 From: dannyKBjj Date: Thu, 14 Nov 2024 16:46:24 +0000 Subject: [PATCH 07/14] added tests.ps1 --- ...IntuneMobileAppConfigurationPolicyIOS.psm1 | 2 +- ...eMobileAppConfigurationPolicyIOS.Tests.ps1 | 281 ++++++++++++++++++ 2 files changed, 282 insertions(+), 1 deletion(-) create mode 100644 Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneMobileAppConfigurationPolicyIOS.Tests.ps1 diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 index 7349c643b8..bf6fe466f9 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 @@ -99,7 +99,7 @@ function Get-TargetResource try { if (-not [string]::IsNullOrWhiteSpace($id)){ $getValue = Get-MgBetaDeviceAppManagementMobileAppConfiguration -ManagedDeviceMobileAppConfigurationId $id -ErrorAction SilentlyContinue } - + #region resource generator code if ($null -eq $getValue) { diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneMobileAppConfigurationPolicyIOS.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneMobileAppConfigurationPolicyIOS.Tests.ps1 new file mode 100644 index 0000000000..b5c34c57f6 --- /dev/null +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneMobileAppConfigurationPolicyIOS.Tests.ps1 @@ -0,0 +1,281 @@ +[CmdletBinding()] +param( +) +$M365DSCTestFolder = Join-Path -Path $PSScriptRoot ` + -ChildPath '..\..\Unit' ` + -Resolve +$CmdletModule = (Join-Path -Path $M365DSCTestFolder ` + -ChildPath '\Stubs\Microsoft365.psm1' ` + -Resolve) +$GenericStubPath = (Join-Path -Path $M365DSCTestFolder ` + -ChildPath '\Stubs\Generic.psm1' ` + -Resolve) +Import-Module -Name (Join-Path -Path $M365DSCTestFolder ` + -ChildPath '\UnitTestHelper.psm1' ` + -Resolve) + +$Global:DscHelper = New-M365DscUnitTestHelper -StubModule $CmdletModule ` + -DscResource 'IntuneMobileAppConfigurationPolicyIOS' -GenericStubModule $GenericStubPath +Describe -Name $Global:DscHelper.DescribeHeader -Fixture { + InModuleScope -ModuleName $Global:DscHelper.ModuleName -ScriptBlock { + Invoke-Command -ScriptBlock $Global:DscHelper.InitializeScript -NoNewScope + BeforeAll { + $secpasswd = ConvertTo-SecureString ((New-Guid).ToString()) -AsPlainText -Force + $Credential = New-Object System.Management.Automation.PSCredential ('tenantadmin@mydomain.com', $secpasswd) + + Mock -CommandName Confirm-M365DSCDependencies -MockWith { + } + + Mock -CommandName New-M365DSCConnection -MockWith { + return 'Credentials' + } + + Mock -CommandName Update-MgBetaDeviceAppManagementMobileAppConfiguration -MockWith { + } + + Mock -CommandName New-MgBetaDeviceAppManagementMobileAppConfiguration -MockWith { + } + + Mock -CommandName Remove-MgBetaDeviceAppManagementMobileAppConfiguration -MockWith { + } + + Mock -CommandName Get-MgBetaDeviceManagementDeviceCompliancePolicyAssignment -MockWith { + + return @() + } + Mock -CommandName Update-DeviceConfigurationPolicyAssignment -MockWith { + } + # Mock Write-Host to hide output during the tests + Mock -CommandName Write-Host -MockWith { + } + $Script:exportedInstances =$null + $Script:ExportMode = $false + } + + # Test contexts + Context -Name "When the iOS Mobile App Configuration Policy doesn't already exist" -Fixture { + BeforeAll { + $testParams = @{ + DisplayName = 'Test iOS Mobile App Configuration Policy' + Description = 'Test iOS Mobile App Configuration Policy Description' + targetedMobileApps = "{FakeStringValue}" + settings = [CimInstance[]]@( + (New-CimInstance -ClassName MSFT_appConfigurationSettingItem -Property @{ + appConfigKey = "FakeStringValue" + appConfigKeyType = "stringType" + appConfigKeyValue = "FakeStringValue" + } -ClientOnly) + ) + encodedSettingXml = "" + Ensure = 'Present' + Credential = $Credential + } + + Mock -CommandName Get-MgBetaDeviceAppManagementMobileAppConfiguration -MockWith { + return $null + } + } + + It 'Should return absent from the Get method' { + (Get-TargetResource @testParams).Ensure | Should -Be 'Absent' + } + + It 'Should return false from the Test method' { + Test-TargetResource @testParams | Should -Be $false + } + + It 'Should create the iOS Mobile App Configuration Policy from the Set method' { + Set-TargetResource @testParams + Should -Invoke -CommandName 'New-MgBetaDeviceAppManagementMobileAppConfiguration' -Exactly 1 + } + } + + Context -Name 'When the iOS Mobile App Configuration Policy already exists and is NOT in the Desired State' -Fixture { + BeforeAll { + $testParams = @{ + DisplayName = 'Test iOS Mobile App Configuration Policy' + Description = 'Test iOS Mobile App Configuration Policy Description' + targetedMobileApps = "{FakeStringValue}" + settings = [CimInstance[]]@( + (New-CimInstance -ClassName MSFT_appConfigurationSettingItem -Property @{ + appConfigKey = "FakeStringValue" + appConfigKeyType = "stringType" + appConfigKeyValue = "FakeStringValue" + } -ClientOnly) + ) + encodedSettingXml = "" + Ensure = 'Present' + Credential = $Credential + } + + Mock -CommandName Get-MgBetaDeviceAppManagementMobileAppConfiguration -MockWith { + return @{ + DisplayName = 'Test iOS Mobile App Configuration Policy' + Description = 'Different Value' + Id = 'e30954ac-a65e-4dcb-ab79-91d45f3c52b4' + targetedMobileApps = "{FakeStringValue}" + AdditionalProperties = @{ + settings = @( + @{ + appConfigKey = "FakeStringValue" + appConfigKeyType = "stringType" + appConfigKeyValue = "FakeStringValue" + } + ) + encodedSettingXml = "" + '@odata.type' = '#microsoft.graph.iosMobileAppConfiguration' + } + } + } + } + + It 'Should return Present from the Get method' { + (Get-TargetResource @testParams).Ensure | Should -Be 'Present' + } + + It 'Should return false from the Test method' { + Test-TargetResource @testParams | Should -Be $false + } + + It 'Should update the iOS Mobile App Configuration Policy from the Set method' { + Set-TargetResource @testParams + Should -Invoke -CommandName Update-MgBetaDeviceAppManagementMobileAppConfiguration -Exactly 1 + + } + } + + Context -Name 'When the policy already exists and IS in the Desired State' -Fixture { + BeforeAll { + $testParams = @{ + DisplayName = 'Test iOS Mobile App Configuration Policy' + Description = 'Test iOS Mobile App Configuration Policy Description' + targetedMobileApps = "{FakeStringValue}" + settings = [CimInstance[]]@( + (New-CimInstance -ClassName MSFT_appConfigurationSettingItem -Property @{ + appConfigKey = "FakeStringValue" + appConfigKeyType = "stringType" + appConfigKeyValue = "FakeStringValue" + } -ClientOnly) + ) + encodedSettingXml = "" + Ensure = 'Present' + Credential = $Credential + } + + Mock -CommandName Get-MgBetaDeviceAppManagementMobileAppConfiguration -MockWith { + return @{ + DisplayName = 'Test iOS Mobile App Configuration Policy' + Description = 'Test iOS Mobile App Configuration Policy Description' + Id = 'e30954ac-a65e-4dcb-ab79-91d45f3c52b4' + targetedMobileApps = "{FakeStringValue}" + AdditionalProperties = @{ + settings = @( + @{ + appConfigKey = "FakeStringValue" + appConfigKeyType = "stringType" + appConfigKeyValue = "FakeStringValue" + } + ) + encodedSettingXml = "" + '@odata.type' = '#microsoft.graph.iosMobileAppConfiguration' + } + } + } + } + + It 'Should return true from the Test method' { + Test-TargetResource @testParams | Should -Be $true + } + } + + Context -Name 'When the policy exists and it SHOULD NOT' -Fixture { + BeforeAll { + $testParams = @{ + DisplayName = 'Test iOS Mobile App Configuration Policy' + Description = 'Test iOS Mobile App Configuration Policy Description' + targetedMobileApps = "{FakeStringValue}" + settings = [CimInstance[]]@( + (New-CimInstance -ClassName MSFT_appConfigurationSettingItem -Property @{ + appConfigKey = "FakeStringValue" + appConfigKeyType = "stringType" + appConfigKeyValue = "FakeStringValue" + } -ClientOnly) + ) + encodedSettingXml = "" + Ensure = 'Absent' + Credential = $Credential + } + + Mock -CommandName Get-MgBetaDeviceAppManagementMobileAppConfiguration -MockWith { + return @{ + DisplayName = 'Test iOS Mobile App Configuration Policy' + Description = 'Test iOS Mobile App Configuration Policy Description' + Id = 'e30954ac-a65e-4dcb-ab79-91d45f3c52b4' + AdditionalProperties = @{ + targetedMobileApps = "{FakeStringValue}" + settings = @( + @{ + appConfigKey = "FakeStringValue" + appConfigKeyType = "stringType" + appConfigKeyValue = "FakeStringValue" + } + ) + encodedSettingXml = "" + '@odata.type' = '#microsoft.graph.iosMobileAppConfiguration' + } + } + } + } + + It 'Should return Present from the Get method' { + (Get-TargetResource @testParams).Ensure | Should -Be 'Present' + } + + It 'Should return true from the Test method' { + Test-TargetResource @testParams | Should -Be $false + } + + It 'Should remove the iOS Mobile App Configuration Policy from the Set method' { + Set-TargetResource @testParams + Should -Invoke -CommandName Remove-MgBetaDeviceAppManagementMobileAppConfiguration -Exactly 1 + } + } + + Context -Name 'ReverseDSC Tests' -Fixture { + BeforeAll { + $Global:CurrentModeIsExport = $true + $Global:PartialExportFileName = "$(New-Guid).partial.ps1" + $testParams = @{ + Credential = $Credential + } + + Mock -CommandName Get-MgBetaDeviceAppManagementMobileAppConfiguration -MockWith { + return @{ + DisplayName = 'Test iOS Mobile App Configuration Policy' + Description = 'Test iOS Mobile App Configuration Policy Description' + Id = 'e30954ac-a65e-4dcb-ab79-91d45f3c52b4' + targetedMobileApps = "{FakeStringValue}" + AdditionalProperties = @{ + settings = @( + @{ + appConfigKey = "FakeStringValue" + appConfigKeyType = "stringType" + appConfigKeyValue = "FakeStringValue" + } + ) + encodedSettingXml = "" + '@odata.type' = '#microsoft.graph.iosMobileAppConfiguration' + } + } + } + } + + It 'Should Reverse Engineer resource from the Export method' { + $result = Export-TargetResource @testParams + $result | Should -Not -BeNullOrEmpty + } + } + } +} + +Invoke-Command -ScriptBlock $Global:DscHelper.CleanupScript -NoNewScope \ No newline at end of file From 0fb436a66e98ce4150aebe2edae66f6c6e8269ed Mon Sep 17 00:00:00 2001 From: dannyKBjj Date: Thu, 14 Nov 2024 17:32:04 +0000 Subject: [PATCH 08/14] added examples create,update and remove examples added --- .../1-Create.ps1 | 49 +++++++++++++++++++ .../2-Update.ps1 | 46 +++++++++++++++++ .../3-Remove.ps1 | 36 ++++++++++++++ 3 files changed, 131 insertions(+) create mode 100644 Modules/Microsoft365DSC/Examples/Resources/IntuneMobileAppConfigurationPolicyIOS/1-Create.ps1 create mode 100644 Modules/Microsoft365DSC/Examples/Resources/IntuneMobileAppConfigurationPolicyIOS/2-Update.ps1 create mode 100644 Modules/Microsoft365DSC/Examples/Resources/IntuneMobileAppConfigurationPolicyIOS/3-Remove.ps1 diff --git a/Modules/Microsoft365DSC/Examples/Resources/IntuneMobileAppConfigurationPolicyIOS/1-Create.ps1 b/Modules/Microsoft365DSC/Examples/Resources/IntuneMobileAppConfigurationPolicyIOS/1-Create.ps1 new file mode 100644 index 0000000000..3a7985ec2b --- /dev/null +++ b/Modules/Microsoft365DSC/Examples/Resources/IntuneMobileAppConfigurationPolicyIOS/1-Create.ps1 @@ -0,0 +1,49 @@ +<# +This example creates a new Intune Mobile App Configuration Policy for iOs devices +#> + +Configuration Example +{ + param( + [Parameter()] + [System.String] + $ApplicationId, + + [Parameter()] + [System.String] + $TenantId, + + [Parameter()] + [System.String] + $CertificateThumbprint + ) + + + Import-DscResource -ModuleName 'Microsoft365DSC' + + Node localhost + { + IntuneMobileAppConfigurationPolicyIOS "ConfigureIntuneMobileAppConfigurationPolicyIOS" + { + Description = "IntuneMobileAppConfigurationPolicyIOS Description"; + DisplayName = "IntuneMobileAppConfigurationPolicyIOS DisplayName"; + Ensure = "Present"; + settings = @( + MSFT_appConfigurationSettingItem{ + appConfigKey = 'ConfigKey1' + appConfigKeyType = 'stringType' + appConfigKeyValue = 'KeyValue1' + } + MSFT_appConfigurationSettingItem{ + appConfigKey = 'ConfigKey2' + appConfigKeyType = 'stringType' + appConfigKeyValue = 'keyValue2' + } + ); + targetedMobileApps = @("06131066-8adf-42a9-86aa-e4b59e27da5d"); + ApplicationId = $ApplicationId; + TenantId = $TenantId; + CertificateThumbprint = $CertificateThumbprint; + } + } +} diff --git a/Modules/Microsoft365DSC/Examples/Resources/IntuneMobileAppConfigurationPolicyIOS/2-Update.ps1 b/Modules/Microsoft365DSC/Examples/Resources/IntuneMobileAppConfigurationPolicyIOS/2-Update.ps1 new file mode 100644 index 0000000000..93d0a39b85 --- /dev/null +++ b/Modules/Microsoft365DSC/Examples/Resources/IntuneMobileAppConfigurationPolicyIOS/2-Update.ps1 @@ -0,0 +1,46 @@ +<# +This example creates a new Intune Mobile App Configuration Policy for iOs devices +#> + +Configuration Example +{ + param( + [Parameter()] + [System.String] + $ApplicationId, + + [Parameter()] + [System.String] + $TenantId, + + [Parameter()] + [System.String] + $CertificateThumbprint + ) + + Node localhost + { + IntuneMobileAppConfigurationPolicyIOS "ConfigureIntuneMobileAppConfigurationPolicyIOS" + { + Description = "IntuneMobileAppConfigurationPolicyIOS Description"; + DisplayName = "IntuneMobileAppConfigurationPolicyIOS DisplayName"; + Ensure = "Present"; + settings = @( + MSFT_appConfigurationSettingItem{ + appConfigKey = 'ConfigKey1' + appConfigKeyType = 'stringType' + appConfigKeyValue = 'KeyValue1 updated' #updated property + } + MSFT_appConfigurationSettingItem{ + appConfigKey = 'ConfigKey2' + appConfigKeyType = 'stringType' + appConfigKeyValue = 'keyValue2' + } + ); + targetedMobileApps = @("06131066-8adf-42a9-86aa-e4b59e27da5d"); + ApplicationId = $ApplicationId; + TenantId = $TenantId; + CertificateThumbprint = $CertificateThumbprint; + } + } +} diff --git a/Modules/Microsoft365DSC/Examples/Resources/IntuneMobileAppConfigurationPolicyIOS/3-Remove.ps1 b/Modules/Microsoft365DSC/Examples/Resources/IntuneMobileAppConfigurationPolicyIOS/3-Remove.ps1 new file mode 100644 index 0000000000..83d7603515 --- /dev/null +++ b/Modules/Microsoft365DSC/Examples/Resources/IntuneMobileAppConfigurationPolicyIOS/3-Remove.ps1 @@ -0,0 +1,36 @@ +<# +This example creates a new Intune Mobile App Configuration Policy for iOs devices +#> + +Configuration Example +{ + param( + [Parameter()] + [System.String] + $ApplicationId, + + [Parameter()] + [System.String] + $TenantId, + + [Parameter()] + [System.String] + $CertificateThumbprint + ) + + + Import-DscResource -ModuleName 'Microsoft365DSC' + + Node localhost + { + IntuneMobileAppConfigurationPolicyIOS "ConfigureIntuneMobileAppConfigurationPolicyIOS" + { + Description = "IntuneMobileAppConfigurationPolicyIOS Description"; + DisplayName = "IntuneMobileAppConfigurationPolicyIOS DisplayName"; + Ensure = "Absent"; + ApplicationId = $ApplicationId; + TenantId = $TenantId; + CertificateThumbprint = $CertificateThumbprint; + } + } +} From 04c404598bcd80a4fcc2f882b2f8233f4c4af8e2 Mon Sep 17 00:00:00 2001 From: dannyKBjj Date: Sat, 16 Nov 2024 20:58:47 +0000 Subject: [PATCH 09/14] Requested changes made Group.Read.All permission added to settings.json Excessive number of blank lines reduced for readability. --- ...IntuneMobileAppConfigurationPolicyIOS.psm1 | 54 ++++--------------- .../settings.json | 12 +++++ 2 files changed, 21 insertions(+), 45 deletions(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 index bf6fe466f9..93a0f1e76c 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 @@ -4,7 +4,7 @@ function Get-TargetResource [OutputType([System.Collections.Hashtable])] param ( - #region resource generator code + #region Intune resource parameters [Parameter()] [System.String] $Id, @@ -29,11 +29,10 @@ function Get-TargetResource [System.String] $encodedSettingXml, - #====================== - #standard params [Parameter()] [Microsoft.Management.Infrastructure.CimInstance[]] $Assignments, + #endregion [Parameter()] @@ -68,7 +67,6 @@ function Get-TargetResource [Parameter()] [System.String[]] $AccessTokens - ) try @@ -133,19 +131,14 @@ function Get-TargetResource } } - - - $results = @{ #region resource generator code Id = $getValue.Id Description = $getValue.Description - DisplayName = $getValue.DisplayName - + DisplayName = $getValue.DisplayName targetedMobileApps = $getValue.TargetedMobileApps settings = $complexSettings #$getValue.AdditionalProperties.settings encodedSettingXml = $getValue.AdditionalProperties.encodedSettingXml - Ensure = 'Present' Credential = $Credential ApplicationId = $ApplicationId @@ -158,8 +151,6 @@ function Get-TargetResource } - - $assignmentsValues = Get-MgBetaDeviceAppManagementMobileAppConfigurationAssignment -ManagedDeviceMobileAppConfigurationId $Results.Id $assignmentResult = @() if ($assignmentsValues.Count -gt 0) @@ -189,7 +180,7 @@ function Set-TargetResource [CmdletBinding()] param ( - #region resource generator code + #region Intune resource parameters [Parameter()] [System.String] $Id, @@ -214,11 +205,10 @@ function Set-TargetResource [System.String] $encodedSettingXml, - #====================== - #standard params [Parameter()] [Microsoft.Management.Infrastructure.CimInstance[]] $Assignments, + #endregion [Parameter()] @@ -288,17 +278,12 @@ function Set-TargetResource $PSBoundParameters.Remove('ManagedIdentity') | Out-Null $PSBoundParameters.Remove('AccessTokens') | Out-Null - - - if ($Ensure -eq 'Present' -and $currentInstance.Ensure -eq 'Absent') { Write-Verbose -Message "Creating {$DisplayName}" $PSBoundParameters.Remove('Assignments') | Out-Null - $CreateParameters = ([Hashtable]$PSBoundParameters).clone() $CreateParameters = Rename-M365DSCCimInstanceParameter -Properties $CreateParameters - $AdditionalProperties = Get-M365DSCAdditionalProperties -Properties ($CreateParameters) foreach ($key in $AdditionalProperties.keys) @@ -321,8 +306,6 @@ function Set-TargetResource } } - - $CreateParameters.add('AdditionalProperties', $AdditionalProperties) #region resource generator code @@ -341,10 +324,8 @@ function Set-TargetResource { Write-Verbose -Message "Updating {$DisplayName}" $PSBoundParameters.Remove('Assignments') | Out-Null - $UpdateParameters = ([Hashtable]$PSBoundParameters).clone() $UpdateParameters = Rename-M365DSCCimInstanceParameter -Properties $UpdateParameters - $AdditionalProperties = Get-M365DSCAdditionalProperties -Properties ($UpdateParameters) foreach ($key in $AdditionalProperties.keys) { @@ -365,8 +346,8 @@ function Set-TargetResource $UpdateParameters[$key] = Convert-M365DSCDRGComplexTypeToHashtable -ComplexObject $UpdateParameters[$key] } } - $UpdateParameters.add('AdditionalProperties', $AdditionalProperties) + $UpdateParameters.add('AdditionalProperties', $AdditionalProperties) #region resource generator code Update-MgBetaDeviceAppManagementMobileAppConfiguration @UpdateParameters ` @@ -392,7 +373,7 @@ function Test-TargetResource [OutputType([System.Boolean])] param ( - #region resource generator code + #region Intune resource parameters [Parameter()] [System.String] $Id, @@ -417,11 +398,10 @@ function Test-TargetResource [System.String] $encodedSettingXml, - #====================== - #standard params [Parameter()] [Microsoft.Management.Infrastructure.CimInstance[]] $Assignments, + #endregion [Parameter()] @@ -502,7 +482,6 @@ function Test-TargetResource $testResult = Compare-M365DSCComplexObject ` -Source (Get-M365DSCDRGComplexTypeToHashtable -ComplexObject $CIMArraySource[$i]) ` -Target ($CIMArrayTarget[$i]) - $i++ if (-Not $testResult) { @@ -603,7 +582,6 @@ function Export-TargetResource try { - #region resource generator code [array]$getValue = Get-MgBetaDeviceAppManagementMobileAppConfiguration -Filter $Filter -All ` -ErrorAction Stop | Where-Object ` @@ -660,8 +638,6 @@ function Export-TargetResource } } - - if ($null -ne $Results.settings) { $complexTypeStringResult = Get-M365DSCDRGComplexTypeToString ` @@ -677,22 +653,12 @@ function Export-TargetResource } } - - - - - - - $currentDSCBlock = Get-M365DSCExportContentForResource -ResourceName $ResourceName ` -ConnectionMode $ConnectionMode ` -ModulePath $PSScriptRoot ` -Results $Results ` -Credential $Credential - - - if ($Results.Assignments) { $isCIMArray = $false @@ -702,8 +668,7 @@ function Export-TargetResource } $currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock -ParameterName 'Assignments' -IsCIMArray:$isCIMArray } - - + if ($Results.settings) { $isCIMArray = $false @@ -714,7 +679,6 @@ function Export-TargetResource $currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock -ParameterName 'settings' -IsCIMArray:$isCIMArray } - $dscContent += $currentDSCBlock Save-M365DSCPartialExport -Content $currentDSCBlock ` -FileName $Global:PartialExportFileName diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/settings.json b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/settings.json index ebd0a5e8d5..520b5bcd32 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/settings.json +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/settings.json @@ -6,10 +6,16 @@ "delegated": { "read": [ { + "name": "Group.Read.All" + }, +{ "name": "DeviceManagementApps.Read.All" } ], "update": [ + { + "name": "Group.Read.All" + }, { "name": "DeviceManagementApps.ReadWrite.All" } @@ -17,11 +23,17 @@ }, "application": { "read": [ + { + "name": "Group.Read.All" + }, { "name": "DeviceManagementApps.Read.All" } ], "update": [ + { + "name": "Group.Read.All" + }, { "name": "DeviceManagementApps.ReadWrite.All" } From a0fc56654c6a911edb1dfcffdaa094a0b5d48461 Mon Sep 17 00:00:00 2001 From: dannyKBjj Date: Mon, 18 Nov 2024 08:54:51 +0000 Subject: [PATCH 10/14] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8d1c06fd6..e74f859000 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,8 @@ * DEPENDENCIES * Updated DSCParser to version 2.0.0.12. * Updated MSCloudLoginAssistant to version 1.1.28. +* MSFT_IntuneMobileAppConfigurationPolicyIOS + * Initial release. # 1.24.1106.3 From ab645b519285eb6717118872eec1a66960d3247e Mon Sep 17 00:00:00 2001 From: dannyKBjj Date: Tue, 19 Nov 2024 15:51:21 +0000 Subject: [PATCH 11/14] Update Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 Co-authored-by: FabienTschanz <71251572+FabienTschanz@users.noreply.github.com> --- .../MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 index 93a0f1e76c..12deb1f16e 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 @@ -114,7 +114,7 @@ function Get-TargetResource return $nullResult } - Write-Verbose -Message "Found something with id {$id}" + Write-Verbose -Message "An Intune Mobile App Configuration Policy for iOS with Id {$id} and DisplayName {$DisplayName} was found" #need to convert dictionary object into a hashtable array so we can work with it $complexSettings = @() From 629911f0aca102b1947f4b212176d230c2c0152e Mon Sep 17 00:00:00 2001 From: dannyKBjj Date: Tue, 19 Nov 2024 15:51:29 +0000 Subject: [PATCH 12/14] Update Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 Co-authored-by: FabienTschanz <71251572+FabienTschanz@users.noreply.github.com> --- .../MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 index 12deb1f16e..435b3082f5 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 @@ -110,7 +110,7 @@ function Get-TargetResource if ($null -eq $getValue) { - Write-Verbose -Message "Nothing with id {$id} was found" + Write-Verbose -Message "No Intune Mobile App Configuration Policy for iOS with Id {$id} was found" return $nullResult } From b917c16920eec9e311e47c8cd2f380017647fa32 Mon Sep 17 00:00:00 2001 From: dannyKBjj Date: Tue, 19 Nov 2024 15:52:28 +0000 Subject: [PATCH 13/14] Removed blank lines from schema.mof --- ...IntuneMobileAppConfigurationPolicyIOS.psm1 | 4 ++-- ...MobileAppConfigurationPolicyIOS.schema.mof | Bin 7984 -> 7964 bytes 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 index 93a0f1e76c..435b3082f5 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.psm1 @@ -110,11 +110,11 @@ function Get-TargetResource if ($null -eq $getValue) { - Write-Verbose -Message "Nothing with id {$id} was found" + Write-Verbose -Message "No Intune Mobile App Configuration Policy for iOS with Id {$id} was found" return $nullResult } - Write-Verbose -Message "Found something with id {$id}" + Write-Verbose -Message "An Intune Mobile App Configuration Policy for iOS with Id {$id} and DisplayName {$DisplayName} was found" #need to convert dictionary object into a hashtable array so we can work with it $complexSettings = @() diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.schema.mof b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneMobileAppConfigurationPolicyIOS/MSFT_IntuneMobileAppConfigurationPolicyIOS.schema.mof index d09774961eca88ea67455f618794f1c369cb29e0..e35b7bfd7e830e2da307639e00a117e49ab0e2f3 100644 GIT binary patch delta 48 zcmdmBH^**+3ioCOZZnq2D%=K}`}mWXC+`q6+N>r#jS0;7B&x^BQOjV>z{|kJ004fo B4bK1o delta 51 zcmbPZx4~|M3isqFeuK>s+)ON+gZO7LPuyU(Sx$Hw)8-ALDVzel3|tH#T+3h$rU9BH B42A#z From 3d70c541cde836c780e44e643b64f6b6f0570969 Mon Sep 17 00:00:00 2001 From: dannyKBjj Date: Wed, 20 Nov 2024 12:38:11 +0000 Subject: [PATCH 14/14] Fixed issues raised on previous pull request --- CHANGELOG.md | 4 ++-- .../IntuneMobileAppConfigurationPolicyIOS/1-Create.ps1 | 2 -- .../IntuneMobileAppConfigurationPolicyIOS/2-Update.ps1 | 1 + .../IntuneMobileAppConfigurationPolicyIOS/3-Remove.ps1 | 2 -- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e74f859000..04512b2702 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ * IntuneAntivirusPolicyWindows10SettingCatalog * Update properties to be upper-case. Fixes [#5373](https://github.com/microsoft/Microsoft365DSC/issues/5373) +* IntuneMobileAppConfigurationPolicyIOS + * Initial release. * IntuneSecurityBaselineMicrosoftEdge * Deprecate property `authschemes` and replace with `AuthSchemes_AuthSchemes` * M365DSCDRGUtil @@ -23,8 +25,6 @@ * DEPENDENCIES * Updated DSCParser to version 2.0.0.12. * Updated MSCloudLoginAssistant to version 1.1.28. -* MSFT_IntuneMobileAppConfigurationPolicyIOS - * Initial release. # 1.24.1106.3 diff --git a/Modules/Microsoft365DSC/Examples/Resources/IntuneMobileAppConfigurationPolicyIOS/1-Create.ps1 b/Modules/Microsoft365DSC/Examples/Resources/IntuneMobileAppConfigurationPolicyIOS/1-Create.ps1 index 3a7985ec2b..80d6ca10e7 100644 --- a/Modules/Microsoft365DSC/Examples/Resources/IntuneMobileAppConfigurationPolicyIOS/1-Create.ps1 +++ b/Modules/Microsoft365DSC/Examples/Resources/IntuneMobileAppConfigurationPolicyIOS/1-Create.ps1 @@ -17,8 +17,6 @@ Configuration Example [System.String] $CertificateThumbprint ) - - Import-DscResource -ModuleName 'Microsoft365DSC' Node localhost diff --git a/Modules/Microsoft365DSC/Examples/Resources/IntuneMobileAppConfigurationPolicyIOS/2-Update.ps1 b/Modules/Microsoft365DSC/Examples/Resources/IntuneMobileAppConfigurationPolicyIOS/2-Update.ps1 index 93d0a39b85..860a8c9732 100644 --- a/Modules/Microsoft365DSC/Examples/Resources/IntuneMobileAppConfigurationPolicyIOS/2-Update.ps1 +++ b/Modules/Microsoft365DSC/Examples/Resources/IntuneMobileAppConfigurationPolicyIOS/2-Update.ps1 @@ -17,6 +17,7 @@ Configuration Example [System.String] $CertificateThumbprint ) + Import-DscResource -ModuleName 'Microsoft365DSC' Node localhost { diff --git a/Modules/Microsoft365DSC/Examples/Resources/IntuneMobileAppConfigurationPolicyIOS/3-Remove.ps1 b/Modules/Microsoft365DSC/Examples/Resources/IntuneMobileAppConfigurationPolicyIOS/3-Remove.ps1 index 83d7603515..6e04d55179 100644 --- a/Modules/Microsoft365DSC/Examples/Resources/IntuneMobileAppConfigurationPolicyIOS/3-Remove.ps1 +++ b/Modules/Microsoft365DSC/Examples/Resources/IntuneMobileAppConfigurationPolicyIOS/3-Remove.ps1 @@ -17,8 +17,6 @@ Configuration Example [System.String] $CertificateThumbprint ) - - Import-DscResource -ModuleName 'Microsoft365DSC' Node localhost