Recently, I found a few Windows autopilot devices where the group tag was missing or the incorrect region group tag was assigned.e.g., US instead of EUROPE, due to which devices were not getting added to the correct dynamic group as per device region. So, we cannot update a single device group tag as that will take a long time, and let's use some automation to get it done so we can update the missing group tag or override the incorrect group tag assigned to any device.
The following methods are available to update the group tag for new and existing Windows Autopilot devices:
GitHub Link for the script: https://github.com/mrintune/Intune/tree/main
Connect-MSGraph Update-MSGraphEnvironment -SchemaVersion "Beta" -Quiet Connect-MSGraph -Quiet #Change the content path with location of txt file in Line6 $Serialnumbers = Get-Content 'C:\Users\Testing\Desktop\Bulk group tag change\Targeted device serial numbers.txt' $autopilotDevices = Invoke-MSGraphRequest -HttpMethod GET -Url "deviceManagement/windowsAutopilotDeviceIdentities" | Get-MSGraphAllPages #Change the Group Tag in Line18 foreach($autopilotDevice in $autopilotDevices) { foreach($Serialnumber in $serialnumbers) { if($autopilotDevice.serialNumber -eq $Serialnumber) { Write-Host "Matched, adding group tag to serial number" + $Serialnumber $autopilotDevice.groupTag = "US" $requestBody= @" { groupTag: `"$($autopilotDevice.groupTag)`", } "@ Invoke-MSGraphRequest -HttpMethod POST -Content $requestBody -Url "deviceManagement/windowsAutopilotDeviceIdentities/$($autopilotDevice.id)/UpdateDeviceProperties" } else { write-host "Skipping Serial Number " + $Serialnumber } } }
0 Comments
Leave a comment