Intune Managed Devices SyncAll

Tim Beer
2 min readFeb 4, 2018

--

(Powershell script from GitHub at end of post)

I was playing around again with some of Dave Falkus’s amazing Intune Powershell scripts, my own Powershell skills leave a lot to be desired.

My goal was to be able to sync all managed devices i.e Androids, Apple iOS and Windows devices. Using the UI or Microsoft Graph this can only be achieved one at a time by getting the Deviced ID and putting in a POST command to sync that specific device.

Dave has a script that checks for any devices that hasn’t been synced in 30 days and is easily modified to change that to a shorter amount of time.

I wanted minutes so have changed the time to minutes, the original script looks for devices that have not synced and displayed them so I have added a POST command to the end of this script to say those devices that haven’t synced DEVICESYNC

When I have more time I will add some more filters and possibly a Menu to choose only Android, iOS, Windows etc

The section I have added to Dave Falkus’s original script is here

$Resource = “deviceManagement/managedDevices/$DeviceID/syncDevice”
$uri = “https://graph.microsoft.com/beta/$($resource)"
write-verbose $uri
Write-Verbose “Sending deviceSync command to $DeviceID”
Invoke-RestMethod -Uri $uri -Headers $authToken -Method Post

If you want to change the time it checks for change it in the section

This is on line 164

Time Section

(Important note if you repeatedly run the script you may see some devices that haven’t synced and will try again but these are likely to be devices that are not in use or off) i.e my Android repeatedly said not synced in last 20 mins till I actually used my Android, i gather that it was in standby mode)

— -Edit 10th Feb 2018 I’ve now added the option to choose only MDM devices or EAS, I will be adding a menu to this script when I have time.
You will see from the filter that’s located on lines 189 -200 from this you may also want to play around with your own filters, to use just unhash the line you want and hash the others. In the example below MDM only is chosen.

Here is the Script on GitHub

--

--

Responses (1)