Windows Autopilot – Bulk update Group tags

Embarking on the journey of Autopilot management? Buckle up as we unveil a nifty script that’s about to become your secret weapon for a seamless bulk update of group tags on Autopilot devices. Say goodbye to tedious manual adjustments and wave hello to efficiency at its finest!

Table of Contents

Script Logic

To seamlessly change the group tags of your devices, we’ll leverage the power of two essential cmdlets: Get-AutopilotDevice and Set-AutopilotDevice (the PowerShell package can be found here). The process is straightforward—firstly, we retrieve the Autopilot object using the Get-AutopilotDevice cmdlet. Next, armed with this information, we employ the Set-AutopilotDevice cmdlet to effortlessly assign the new value to the desired group tag. It’s a dynamic duo of cmdlets simplifying the entire process with precision and ease.

Script

# Install-Module -Name Microsoft.Graph
# Install-Module -Name WindowsAutoPilotIntune
# Be sure to have the correct permissions to perform Autopilot related operations

Connect-MgGraph

# Specify the new group tag here
$Grouptag = "NewGroupTag" 

# Get the serial numbers of the devices that we want to change group tag
$serialsTXTFilePathLocation = Read-Host "Enter the txt path location containing the serial numbers:"
$serials = Get-Content -Path $serialsTXTFilePathLocation

foreach($serial in $serials)
{
    Write-Host "Changing Group tag for: $serial"
    Get-AutopilotDevice -serial $serial | Set-AutopilotDevice -groupTag $Grouptag
}

References

Leave a Reply

Your email address will not be published. Required fields are marked *