forked from DeploymentResearch/DRFiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForceSyncOnAllWindowsDevices.ps1
35 lines (26 loc) · 1.03 KB
/
ForceSyncOnAllWindowsDevices.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
$Tenant = Connect-MSGraph -ForceInteractive
# Get all Windows Devices
$Devices = Get-IntuneManagedDevice -Filter "contains(operatingsystem, 'Windows')" | Get-MSGraphAllPages
# Show Device Count
($Devices | Measure-Object).Count
# Report Last Sync, and force sync on each Device
Foreach ($Device in $Devices)
{
Write-Host "Last Sync Time was: $($Device.lastSyncDateTime)"
# Force sync
Invoke-IntuneManagedDeviceSyncDevice -managedDeviceId $Device.managedDeviceId
Write-Host "Sending Sync request to Device with DeviceID $($Device.managedDeviceId)" -ForegroundColor Yellow
Write-Host ""
}
#
# Misc samples
#
# Get all devices
Get-IntuneManagedDevice | Get-MSGraphAllPages
# Get devices for a specific user
$Devices = Get-IntuneManagedDevice | Where-Object {$_.userDisplayName -eq "Johan Arwidmark"}
$Devices | Select deviceName
# Get Devices from wildcard
$Devices = Get-IntuneManagedDevice -Filter "contains(deviceName, '001')"
# Get Single Device
$Devices = Get-IntuneManagedDevice -Filter "deviceName eq 'DA-INTUNE-001'"