Intune – Sync devices

Been forever (like almost 10 years!!!), so I thought maybe I should post something. So here’s a little Powershell script for syncing all devices (by OS/type).

<#
🟪🟨🟦🟧🟩🟪🟨🟦🟧🟩🟪🟨🟦🟧🟩🟪🟨🟦🟧🟩🟪🟨🟦🟧🟩🟪🟨🟦🟧🟩🟪🟨🟦🟧🟩🟪🟨🟦🟧🟩🟪🟨🟦🟧🟩🟪🟨🟦🟧🟩🟪🟨🟦🟧🟩🟪🟨🟦🟧🟩🟪🟨🟦🟧🟩🟪🟨🟦🟧

    Sync all Intune iPads
        Iterate through all iPads and initiate sync

    Version history:
        1.0  -  2024-02-22  -  Neil Nuttall  -  Initial verion

🟩🟧🟦🟨🟪🟩🟧🟦🟨🟪🟩🟧🟦🟨🟪🟩🟧🟦🟨🟪🟩🟧🟦🟨🟪🟩🟧🟦🟨🟪🟩🟧🟦🟨🟪🟩🟧🟦🟨🟪🟩🟧🟦🟨🟪🟩🟧🟦🟨🟪🟩🟧🟦🟨🟪🟩🟧🟦🟨🟪🟩🟧🟦🟨🟪🟩🟧🟦🟨
#>


Import-Module Microsoft.Graph.DeviceManagement.Actions
Connect-Mggraph -scopes DeviceManagementManagedDevices.ReadWrite.All, DeviceManagementManagedDevices.PrivilegedOperations.All -NoWelcome

$alliPads = Get-MgDeviceManagementManagedDevice -all -Filter "OperatingSystem eq 'iOS'"| Where-Object {$_.Model -like "iPad*"}

$i=0

Foreach ($iPad in $alliPads) {
    Sync-MgDeviceManagementManagedDevice -ManagedDeviceId $iPad.id

    $i++
    Write-Progress -Id 1 -Activity "Syncing iPads" -Status $iPad.DeviceName -PercentComplete ($i/$alliPads.Count*100)
}
Write-Progress -Id 1 -Completed
Write-Host "Sync requests sent for $i devices"


Leave a comment