@Sanchez, Javier Adrian Thank you for posting your question in Microsoft Q&A.
You can use the download devices option under All Devices to export the entire information about devices in Microsoft Entra as shown below.
Once you have downloaded the csv file and if you want to create a new csv file with device name and device owner (registered owner name) using the below PowerShell script.
$exportdata=@()
$csvdata= import-csv -Path C:\Users\Downloads\exportDevice_2024-3-26.csv #local drive path
foreach( $item in $csvdata){
$exportdata += [PSCustomObject]@{
DeviceName = $item.displayName
RegisteredOwners = $item.registeredOwners
}
}
$exportdata | Export-Csv -Path C:\Users\Downloads\devicelist.csv -NoTypeInformation #local drive path to create new csv file.
If you want to execute the same above using the Az cmdlets instead of exporting to local drive, then you can use the below script to connect to Microsoft Entra and export the device information to a new csv file.
connect-mggraph -scopes "Directory.Read.All"
$exportdata=@()
$devlist=Get-MgDevice
foreach( $item in $devlist)
{
$ownername= Get-MgDeviceRegisteredOwner -DeviceId $item.Id
$exportdata += [PSCustomObject]@{
DeviceName = $item.displayName
RegisteredOwners = $ownername.AdditionalProperties.displayName
}
}
$exportdata | Export-Csv -path C:\Users\Downloads\deviceinformation.csv
#local drive path to create new csv file
Hope this helps and let me know if you have any further questions on this.