Modern Desktop Architect

Quickly Sync all Intune Devices

A very quick script today but one which I use regularly. There is nothing worse than deploying a new policy or app and then waiting for the machines to check-in, especially if you’ve just missed a cycle.

This script runs through all devices and nudges them along.

As usual it’s on GitHub and PS Gallery

Install-Script -Name SyncAllIntuneDevices

Once logged in and authenticated to MS Graph, it’s fairly basic:

A function to sync a device:

    function SyncDevice {
        $Resource = "deviceManagement/managedDevices('$DeviceID')/syncDevice"
        $uri = "$($resource)"
        write-verbose $uri
        Write-Verbose "Sending sync command to $DeviceID"
        Invoke-RestMethod -Uri $uri -Headers $authToken -Method Post

Wrapped in a loop to go through the devices

$graphApiVersion = "beta"
$Resource = "deviceManagement/managedDevices"
$uri = "$graphApiVersion/$Resource"

$devices = (Invoke-RestMethod -Uri $uri -Headers $authToken -Method Get).Value
foreach ($device in $devices) {
    SyncDevice -Deviceid $
    $devicename = $device.deviceName
    write-host "Sync sent to $devicename"

Simple, but does the job!

Add a Comment

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