Get Computer Name from Azure Device ID

We have multiple RRAS servers, and occasionally, I need to locate which one a client is connected to for troubleshooting. Now the RRAS console has some inconsistencies, sometimes it displays the computer name, sometime the Azure Device ID (Not the object ID)

The Microsoft Docs on the Get-AzureADDevice is woefully incomplete, and it took me some time to figure out how to filter on Device ID.

The correct syntax is:

Get-AzureADDevice -Filter "deviceId eq guid'$guid'"

where $guid is a variable holding the device ID. From this we can then expand to get the actual computer name:

$name = (Get-AzureADDevice -Filter "deviceId eq guid'$guid'").displayname

The important part here is in using the prefix guid before the value, otherwise the filter will spit out an error.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.