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:

Share this

Related Posts

Previous
Next Post »