I used to use scripts from the microsoft graph powershell intune samples, but getting a list of all intune managed devices took a long time and automation was a pain in the (you know what). That was, until I started using the Microsoft.Graph.Intune module.
Though, once your organisation goes over 1000 devices, you might get some results that make you wonder. If you run this command
You might get the above result. You can get a result of the devices by changing the command to this:
But that will only get you the result of the 1000 devices. If you want to get a list of all your devices, you better run this command:
Get-IntuneManagedDevice | Get-MSGraphAllPages
Once you get the list of all your devices, you can filter on all the properties of the objects returned:
So if you want to get a list of all Windows devices, you can run:
Get-IntuneManagedDevice -filter "operatingSystem eq 'Windows'" | Get-MSGraphAllPages
This time there is no complete script to download, as the commands are all in this blog post. Have fun scripting!
If you like this blog post and want to support me so I can create and share more scripts, please consider donating to me through PayPal.