Hi again!
If you looked on my previous post you probably asked yourself how would be able to retrieve the same information using Powershell.
There you go.
Install-Module Microsoft.Graph -Scope AllUsers
Connect-MSGraph
$Devices = Get-IntuneManagedDevice -Filter “contains(operatingsystem, ‘Windows’)” | Get-MSGraphAllPages
Now you have the full list to work with
$Devices | Where-Object {$_azureADDeviceId -eq “00000000-0000-0000-0000-000000000000”} #List All Device On Screen
$Devices | Where-Object {$_.azureADDeviceId -eq “00000000-0000-0000-0000-000000000000”} | select deviceName,serialnumber,userprincipalname #List All Device On Screen filtered by Device Name, Serial Number and UPN
($Devices | Where-Object {$_.azureADDeviceId -eq “00000000-0000-0000-0000-000000000000”} | select deviceName,serialnumber,userprincipalname).count #Count all devices that matches the prior output
Need it on Grid View in Powershell
$Devices | Where-Object {$_.azureADDeviceId -eq “00000000-0000-0000-0000-000000000000”} | select deviceName,serialnumber,userprincipalname | Out-GridView
Need it in HTML format.
$Devices | Where-Object {$_.azureADDeviceId -eq “00000000-0000-0000-0000-000000000000”} | select deviceName,serialnumber,userprincipalname | Out-GridHtml
Download the scripts
- List Stale Devices
- List and Delete Stale Devices (always backup them up to CSV file)
Cheers,
Thiago Beier