Export Device Inventory to CSV
Export the inventory of all managed devices to a CSV file. Use Connect-MSGraph to authenticate and ensure you have the required permissions to manage Intune resources.
Get-IntuneManagedDevice | Select-Object DeviceName, OperatingSystem, DeviceId, ComplianceState | Export-Csv -Path "IntuneDeviceInventory.csv" -NoTypeInformation