Azure AD groups for a specific device.

I’ve been to multiple customers that have asked me about how they can view which Azure AD groups a device is member of. Since there is no way of doing this in the Azure portal (as of March 2020), Hans Zeitler and I created a PowerShell script to do exactly that via Microsoft Graph.

I’ve been to multiple customers that have asked me about how they can view which Azure AD groups a device is member of.

Since there is no way of doing this in the Azure portal (as of March 2020), Hans Zeitler and I created a PowerShell script to do exactly that via Microsoft Graph.

 I also created another script to export all your devices and their group membership to a file.

To run the scripts:

1.    Download the scripts from GitHub – see link at the end of the script – to your own local script repository (e.g. C:\Scripts\)

2.    Open PowerShell.exe

3.    Edit the script you want to run and change the two variables which is also specified at the top of the script:

a.    $scriptPath = <script folder path> # e.g. ‘C:\Scripts\’

b.   $useraccount = <AAD user account> # e.g. ‘admin@contoso.com’

No alt text provided for this image

Get Group Membership for Specific Device.ps1”:

If you type the name of a non-existing device, you’ll be prompted to try again:

No alt text provided for this image

If you type the name of a device, that has multiple entries you’ll be prompted to copy/paste the id of the device you want to check.

No alt text provided for this image

Get Group Membership of ALL Devices.ps1”:

No alt text provided for this image

Script download:

You can download both scripts from my GitHub repository:

https://github.com/larsinus/Public/tree/master/Azure%20AD

Disclaimer:

The sample scripts are not supported under any Microsoft standard support program or service. The sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.