PowerShell to Get a List of Devices from Microsoft Intune
Microsoft Intune is a cloud-based service that helps organizations manage and secure their devices, including mobile devices, laptops, and desktops. With Intune, you can set policies, deploy apps, and protect data across your organization. In this blog post, I will show you how to use PowerShell to get a list of devices from Microsoft Intune. This can be useful if you want to automate the process of managing and tracking your devices, or if you need to generate reports on your device inventory.
To get started with Automating Device Management in Microsoft Intune with PowerShell , you will need to install the Microsoft Intune PowerShell module and authenticate to the Microsoft Graph API. Here are the steps to do this:
Install the Microsoft Intune PowerShell module by running the following command
Install-Module -Name Microsoft.Graph.Intune
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
Connect to the Microsoft Graph API by running the following command:
This will open a web browser window and prompt you to sign in with your Microsoft account. Once you have signed in, the
Connect-MSGraph cmdlet will obtain an access token and establish a connection to the Microsoft Graph API.
Getting a List of Devices from Microsoft Intune
Now that you are connected to the Microsoft Graph API, you can use the
Get-IntuneManagedDevice cmdlet to get a list of all managed devices in Microsoft Intune. Here is an example of how you can use the cmdlet:
$devices = Get-IntuneManagedDevice
foreach ($device in $devices)
Write-Output "Device ID: $($device.DeviceId)"
Write-Output "Display Name: $($device.DisplayName)"
Write-Output "Model: $($device.Model)"
This example will iterate through the list of devices and print the device ID, display name, and model for each device.
You can also use the
-Filter parameter to filter the list of devices based on specific criteria. For example, to get a list of all Android devices, you can use the following command:
$devices = Get-IntuneManagedDevice -Filter "Platform eq 'Android'"
Exporting the List of Devices to a CSV File
To export the list of devices to a file, you can use the
Export-Csv cmdlet to save the list of devices to a CSV file. For example:
$devices | Export-Csv -Path "C:\temp\devices.csv" -NoTypeInformation
This will save the list of devices to a CSV file in the specified location, Exporting Your Device Inventory from Microsoft Intune with PowerShell.
I hope this tutorial “How to Use PowerShell to Get a List of Devices from Microsoft Intune” has helped you learn how to use PowerShell to get a list of devices from Microsoft Intune. If you have any questions or need further assistance, please leave a comment below.