Intune PowerShell Script for Bulk Device Sync

If you are on this page which means you do not wish to go through Intune GUI and select devices manually and run Sync from Bulk device Actions. Below is a PowerShell Script which will Sync all your Devices for you. Its a 4 liner. Code is for Windows Devices but you can change (operatingsystem, ‘Windows’ to iOS or Android or all of them at the same time. Just copy and paste the Code below in Windows PowerShell (I prefer to use PowerShell ISE, easy to change the code and execute). Make sure you connect to your tenant using Connect-MSGraph and login with your Intune Admin or GA account.

Connect-MSGraph
$Devices = Get-IntuneManagedDevice -Filter "contains(operatingsystem, 'Windows')" | Get-MSGraphAllPages
Foreach ($Device in $Devices)
{ 
Invoke-IntuneManagedDeviceSyncDevice -managedDeviceId $Device.managedDeviceId
Write-Host "Sending Sync request to Device with DeviceID $($Device.managedDeviceId)" -ForegroundColor CYAN
}

You will see your output will start coming in CYAN colour with Device ID instead of Device name. You can change output colour to another colour if you wish. Cyan is easily visible and RED looks like errors to me. Output as below:


Add a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.