This article describes how you can export data from AzureAD using the PowerShell.

At first you have to connect your PowerShell with an AzureAD.
To do this we use the connect-azuread commandlet.

This generates a pop-up asking for login credentials.
Use an account that has access to the information you want to export.

Afterwards you should see a line like this.

Getting data

The following Microsoft page provides a good overview of AzureAD related PowerShell commandlets.
https://docs.microsoft.com/en-us/powershell/module/azuread/?view=azureadps-2.0

We use get-azureaddevice to get a list of device objects in this domain.

As you can see the devices have the related information ObjectID, DeviceID and a DisplayName.
These are the values get-azureaddevicedisplays by default but there are way more.
We get an overview of all available values if we take a random device (-objectid) and pipe the output to format list (fl).

In this example I am interested in the values of DisplayName, ObjectId, ObjectType und ApproximateLastLogonTimeStamp.

We can now explicitly list these in a desired order.
get-azureaddevice | select DisplayName, ObjectId, ObjectType, ApproximateLastLogonTimeStamp

 

Exporting the data

For better visibility you can export this data to a CSV file.
To do this we pipe STDOUT to the export-csv commandlet and provide a local storage path.

In this case the command looks like this:
get-azureaddevice | select DisplayName, ObjectId, ObjectType, ApproximateLastLogonTimeStamp | export-csv C:\temp\foo.csv

Now we can open this exported CSV with excel for example.
Just go to File > From Text / CSV.

In the following dialogue we define that the values presented are comma seperated and confirm with load.

This way you can easily sort alphabeticly and provide the output to a customer.

Cheers,
Ori