forked from DeploymentResearch/DRFiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create ForceSyncOnAllWindowsDevices.ps1
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'" |