Microsoft Intune: Force Sync Devices with PowerShell

Published on: July 29, 2021 | Reading Time: 2 min | Last Modified : July 29, 2021

INTUNE : Force Sync device(s) with PowerShell

Today, Let’s know how we can invoke a sync from Intune/MEM console to one or several devices. Current limitation with Intune is, from Intune console we can initiate ‘sync’, one or max 100 device at a time. So let’s talk about all possibilities we can achieve (our) use cases.

Syncing a device from the Intune Portal

From Intune, Go to Devices -> (Select device you want to sync) -> Sync as shown below:

You can also refer to Microsoft’s URL for this for detailed information.

Syncing Multiple devices from the Intune Portal

From Intune, Go to Devices -> All devices-> Bulk devices Actions as shown below:

Now, You should get the option to select OS and then Device Action, select Sync here as depicted below-

It’s time to select devices now (100 max).

This is where I think there should be an option to import device list(csv) or select all device. May be MS kept this for future enhancement 😉

Now, suppose you want to sync multiple devices in a go (One click solution). Here’s how can we achieve this. Here, Powershell and MS Graph comes into picture.

Syncing device(s) using PowerShell

These lines will be prerequisites for all scenarios-

Install-Module -Name Microsoft.Graph.Intune
Import-Module -Name Microsoft.Graph.Intune
Connect-MSGraph


Note: If required, Run Set-ExecutionPolicy -ExecutionPolicy Unrestricted

Scenario 1- For a single device when you know the device name

Get-IntuneManagedDevice -Filter "contains(deviceName,'John phone')" | Invoke-IntuneManagedDeviceSyncDevice


Scenario 2- For all devices whose device names contains specific nomenclature

$Devices = Get-IntuneManagedDevice -Filter "contains(deviceName,'Desktop')" ForEach ($Device in $Devices){$DevID=$device.managedDeviceId Write-Host "Sending Sync request to Device with DeviceID$DevID"
Invoke-IntuneManagedDeviceSyncDevice -managedDeviceId $device.managedDeviceId }  Scenario 3- For devices specific to Operating System $Devices = Get-IntuneManagedDevice -Filter "contains(operatingsystem, 'iOS')"
# $Devices.count (if you want to double check the count if numbers are matching with Intune console) Foreach ($Device in $Devices) { Invoke-IntuneManagedDeviceSyncDevice -managedDeviceId$Device.managedDeviceId
Write-Host "Sending Sync request to Device with DeviceID $($Device.managedDeviceId)"
}


That’s all for today, till then keep exploring & keep learning !! ✌️❤️