Intune – sync all devices in Intune using Powershell

Install Micrsofot Graph Intune
More information : PowerShell Gallery | Microsoft.Graph.Intune 6.1907.1.0

Install-Module -Name Microsoft.Graph.Intune

IMport and Connect to MS Graph

Import-Module -Name Microsoft.Graph.Intune

Sync One device via POwershall MS Graph

#get device information
Get-IntuneManagedDevice -Filter "contains(deviceName,'LT2023')"

#start syncof the device
Get-IntuneManagedDevice -Filter "contains(deviceName,'LT2023')" | Invoke-IntuneManagedDeviceSyncDevice

Sync all devices.

If you have more then 100 devices it’s necessary to use paging.
To check the amount of pages you may use this powershell command : Get-MSGraphAllPages

$Devices = Get-IntuneManagedDevice -Filter "contains(operatingsystem, 'Windows')"

# change windows for iOS or Android to get a filter for the OS systems.
$Devices = Get-IntuneManagedDevice -Filter "contains(operatingsystem, 'iOS')"

#if more then 1000 devices
$Devices = Get-IntuneManagedDevice -Filter “contains(operatingsystem, ‘Windows’)” | Get-MSGraphAllPages

To sync all Devices and have a follow up

Foreach ($Device in $Devices)
Invoke-IntuneManagedDeviceSyncDevice -managedDeviceId $Device.managedDeviceId
Write-Host "Sending Sync request to Device with DeviceID $($Device.managedDeviceId)" -ForegroundColor Red

Leave a Reply

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