All scripts
Microsoft 365 684
Get-IntuneDeviceInventoryReport
Exports a full hardware and enrollment inventory for every managed device (model, serial, OS version, enrollment type, last check in) to a single CSV for asset tracking.
Get-IntuneDeviceInventoryReport.ps1
<#
.SYNOPSIS
Exports full device inventory from Intune.
.DESCRIPTION
Exports model, serial number, OS version, enrollment type and last
check in time for every managed device to a single CSV, useful as a
lightweight asset inventory without a dedicated asset management
tool.
.PARAMETER ExportPath
Path to write the CSV to. Defaults to the current directory.
.EXAMPLE
.\Get-IntuneDeviceInventoryReport.ps1
.NOTES
Requires Microsoft.Graph.DeviceManagement with an active
Connect-MgGraph session.
.AUTHOR
Shehryar Hassan
#>
param(
[string]$ExportPath = (Get-Location).Path
)
$devices = Get-MgDeviceManagementManagedDevice -All
$report = $devices | Select-Object DeviceName, Model, SerialNumber, OperatingSystem, OsVersion,
ManagementAgent, EnrolledDateTime, LastSyncDateTime, UserPrincipalName
$file = Join-Path $ExportPath "intune-device-inventory_$(Get-Date -Format yyyyMMdd_HHmmss).csv"
$report | Export-Csv -Path $file -NoTypeInformation
Write-Host "Exported $($report.Count) device(s) to $file" -ForegroundColor Cyan
Read it before you run it, and test in a safe tenant first.