Loading...

Use PowerShell to list all Azure AD users with their devices and vice-versa


In this post I will show you a quick script that allows you to list and export all your Azure AD users and all their devices.
I will also show you a script that shows all your Azure AD devices with user to which they are attributed.

Context
You want to know which devices is used by a user
You want to know how many devices your users have
You want get informations about all your users in Azure: name, mail, on-prem OU...

Get the scripts

List devices and owners
This will list all Azure AD devices using the cmdlet Get-AzureADDevice.
Then for each device, this will check curent owners using the cmdlet Get-AzureADDeviceRegisteredOwner. 
This will list below informations:
- Device name
- Device last logon
- Is device account enabled ?
- Device OS
- Device OS version
- Device owner count
- Device owner name
- Device owner mail
- Device owner On-Prem OU

See below an export overview in powershell out-gridview:

See below an export overview for a device with multiple users:

See below a CSV export overview:


List users and their devices
This will list all Azure AD devices using the cmdlet Get-AzureADUser.
Then for each user, this will check their devices using the cmdlet Get-AzureADUserRegisteredDevice. 
This will list below informations:
- User name
- User mail
- User On-prem OU
- Is user account enabled ?
- User device count
- Device associated to the user
- Last logon
- Device OS type
- Device OS version

See below an export overview in powershell out-gridview:

See below an export overview for a user with his device:

See below a CSV export overview:

PS1 8934836283975670341

Publier un commentaire

2 commentaires

Anonyme a dit…

Hello! Very grateful for these scripts. They saved me a headache! One question, however, when exported to CSV, all of my data appears in the first column. The out-grid view is fine, it looks normal, but the export-csv on my system looks nothing like it does in your screenshots. Any suggestions?

Anonyme a dit…

install importexcel module and use export-excel instead of export-csv

Accueil item

Award

Mes articles en français

Author of Books

PowerShell GUI & WPF Group

PowerShell GUI & WPF Group

Join the FPSUGR

Join the FPSUGR

Stats