The PowerShell SDK for Intune Graph API helps IT professionals automate and manage their Microsoft Intune environment through PowerShell without going to the Endpoint Manager Admin Center.
In this article, we will see how to export the serial number for multiple devices using the PowerShell module for Intune Graph API. If you don’t have PowerShell SDK installed, check this article to install it and connect it with Microsoft Graph.
Get-IntuneManageDevices cmdlets
This cmdlets can be used to retrieve the details of all Intune managed devices. The below command without any parameters will list all Intune managed devices with all available properties.
Get-IntuneManagedDevice
The result can be filtered using Where-Object cmdlets which filter the output and only show the result which you want to see. Here we used the Where-Object cmdlet to see a single device’s output.
Get-IntuneManagedDevice | Where-Object {$_.deviceName -eq 'TESTVM01'}
The above example will list all properties for a specific device. Now we will use Select-Object cmdlets to only show selected properties in the output.
The below command will show only selected properties (Manufacturer, Model, and Serial number) for specific devices.
Get-IntuneManagedDevice | Where-Object {$_.deviceName -eq 'TESTVM01'} | select-object deviceName,manufacturer,serialnumber
The Script
Let’s see how we can export the details for multiple devices. The below PowerShell script will export the details for multiple devices at once. You need to provide the device name in a CSV file in the below format.
Name the CSV file as ‘Devices.csv’ and copy the same in the script folder. The result will be saved in the ‘Devices_serials.csv’ file in the script directory.
Here is the output in the CSV file
Script:
$inFile = $PSScriptRoot + '\devices.csv'
$outFile = $PSScriptRoot + '\devices_details.csv'
$Results = @()
$devices = Import-csv -Path $inFile
foreach($device in $devices){
$intuneDevice = Get-IntuneManagedDevice | Where-Object { $_.deviceName -eq $device.'Device Name'}
$properties = @{
DeviceName=$device.'Device Name'
Manufacturer=$intuneDevice.manufacturer
Model=$intuneDevice.model
SerialNumber=$intuneDevice.serialNumber
}
$Results += New-Object psobject -Property $properties
}
$Results | Select-Object deviceName,manufacturer,model,serialNumber | Export-Csv -Path $outFile -NoTypeInformation
Related Posts
- Get AAD Group Members Details Using PowerShell SDK for Microsoft Intune Graph API
- How To Export Serial number of Multiple Devices using PowerShell SDK for Intune Graph API
- Install PowerShell SDK for Microsoft Intune Graph API
- How to Export Managed Device Details from Intune
Subscribe to Techuisitive Newsletter
Be the first to know about our new blog posts. Get our newsletters directly in your inbox and stay up to date about Modern Desktop Management technologies & news.