Skip to content

Instantly share code, notes, and snippets.

@Calvindd2f
Created August 18, 2025 22:09
Show Gist options
  • Select an option

  • Save Calvindd2f/69c9d190e378f9afb3617a15cb6076c7 to your computer and use it in GitHub Desktop.

Select an option

Save Calvindd2f/69c9d190e378f9afb3617a15cb6076c7 to your computer and use it in GitHub Desktop.
Intune Policy Strip Unique Identifiers. Strip IntuneManagement UUIDs
# 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)
$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