How to get device owner information based on a list of computers on a CSV file.

Sanchez, Javier Adrian 0 Reputation points
2024-03-25T21:01:20.3166667+00:00

Hi,Please help how to export Azure AD devices with Owner information to CSV.

I would like to pull the device names from a CSV file and export the information about the owners to a new CSV file.

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
21,694 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. VenkateshDodda-MSFT 20,696 Reputation points Microsoft Employee
    2024-03-26T10:36:32.86+00:00

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

    User's image

    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.