In this post, I am going to share Powershell script to find and list devices that are registered by Azure AD users. We can use the Get-AzureADUserRegisteredDevice cmdlet to get the registered devices.
Before proceed run the below command to connect Azure AD Powershell module.
1 | Connect-AzureAD |
List registered devices of all Azure AD users:
To get a report of the device list for all Azure AD users, first, we need to get users by Get-AzureADUser cmdlet and pipe the user list to Get-AzureADUserRegisteredDevice cmdlet.
$Result=@()
$Users = Get-AzureADUser -All $true | Select UserPrincipalName,ObjectId
$Users | ForEach-Object {
$user = $_
Get-AzureADUserRegisteredDevice -ObjectId $user.ObjectId | ForEach-Object {
$Result += New-Object PSObject -property @{
DeviceOwner = $user.UserPrincipalName
DeviceName = $_.DisplayName
DeviceOSType = $_.DeviceOSType
ApproximateLastLogonTimeStamp = $_.ApproximateLastLogonTimeStamp
}
}
}
$Result | Select DeviceOwner,DeviceName,DeviceOSType,ApproximateLastLogonTimeStamp
Export Report to CSV file:
You can export the result to CSV file using the command Export-CSV.
1 | $Result | Export-CSV "C:\AzureADJoinedDevices.csv" -NoTypeInformation -Encoding UTF8 |
Ref: Get Azure AD Users with their Registered Devices using Powershell (morgantechspace.com)