Created
August 18, 2025 22:09
-
-
Save Calvindd2f/69c9d190e378f9afb3617a15cb6076c7 to your computer and use it in GitHub Desktop.
Intune Policy Strip Unique Identifiers. Strip IntuneManagement UUIDs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # It should really be a dynamic group but if hindsight was foresight we would all be millionaires | |
| # POST https://graph.microsoft.com/beta/deviceManagement/configurationPolicies/{policyId}/assign | |
| $policyId = "{policyId}" | |
| $groupId = "{groupId}" | |
| $body = @{ | |
| assignments = @( | |
| @{ | |
| "@odata.type" = "#microsoft.graph.deviceManagementConfigurationPolicyAssignment" | |
| target = @{ | |
| "@odata.type" = "#microsoft.graph.groupAssignmentTarget" | |
| groupId = $groupId | |
| } | |
| } | |
| ) | |
| } | |
| Invoke-MgGraphRequest -Method POST -Uri "/deviceManagement/configurationPolicies/$policyId/assign" `-Body ($body | ConvertTo-Json -Depth 6) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $policy = Get-Content '.\export.json' | ConvertFrom-Json | |
| $clean = [ordered]@{ | |
| '@odata.type' = '#microsoft.graph.deviceManagementConfigurationPolicy' | |
| name = $policy.name | |
| description = $policy.description | |
| platforms = $policy.platforms | |
| technologies = $policy.technologies | |
| roleScopeTagIds = @('0') | |
| settings = @() | |
| templateReference = $policy.templateReference | |
| } | |
| foreach($s in $policy.settings) { | |
| $inst = $s.settingInstance | |
| $inst.PSObject.Properties.Remove('@odata.id') | |
| $inst.PSObject.Properties.Remove('@odata.editLink') | |
| $inst.PSObject.Properties.Remove('id') | |
| $clean.settings += [ordered]@{ | |
| '@odata.type' = '#microsoft.graph.deviceManagementConfigurationSetting' | |
| settingInstance = $inst | |
| } | |
| } | |
| $clean | ConvertTo-Json -Depth 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment