Skip to content

Commit

Permalink
Create ForceSyncOnAllWindowsDevices.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
arwidmark committed Sep 20, 2021
1 parent ec2a0c8 commit a880520
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Scripts/Intune/ForceSyncOnAllWindowsDevices.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
$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')"
$Devices | Select deviceName

# Get Devices from wildcard
$Devices = Get-IntuneManagedDevice -Filter "contains(deviceName, 'DA-INTUNE')"
$Devices | Select deviceName


# Get Single Device
$Devices = Get-IntuneManagedDevice -Filter "deviceName eq 'DA-INTUNE-001'"

0 comments on commit a880520

Please sign in to comment.