How To Export Serial number of Multiple Devices using PowerShell SDK for Intune Graph API

The PowerShell SDK for Intune Graph API help IT professional’s automate and manage their Microsoft Intune environment through PowerShell without going to Endpoint Manager Admin Center.

In this article, we will see how to export the serial number for multiple devices using PowerShell module for Intune Graph API. If you don’t have PowerShell SDK installed, then check this article to install and connect 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.

Intune | Get-IntuneManagedDevice cmdlet | Export Serial Number

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 Where-Object cmdlet to to see the output for a single device.

 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 output.

The below command will show only selected properties (Manufacturer, Model and Serial number) for specific device.

Get-IntuneManagedDevice | Where-Object {$_.deviceName -eq 'TESTVM01'} | select-object deviceName,manufacturer,serialnumber
Intune | Get-IntuneManagedDevice cmdlet

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 below format.

Name CSV file as ‘Devices.csv’ and copy the same in script folder. The result will be saved in ‘Devices_serials.csv’ file in script directory.

Here is the output in CSV file


$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'
 $Results += New-Object psobject -Property $properties
$Results | Select-Object deviceName,manufacturer,model,serialNumber | Export-Csv -Path $outFile -NoTypeInformation

Related Posts

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.

Scroll to Top