How to get security groups for AAD users in bulk using Azure CLI and Azure PowerShell

目次

  1. Introduction

  2. Output File Examples

  3. Input File Examples

  4. Script Description

  5. Summary

Introduction

There are times when you want to retrieve the security groups that Azure AD users belong to in bulk. While it is possible to check for a single user through the portal, it becomes cumbersome when dealing with 100 users. Therefore, in this article, we will introduce a method to retrieve specific security groups that each user belongs to by using Azure CLI and Azure PowerShell to read user information from a CSV file. With this script, you can easily obtain the user information related to security group membership.

Output File Examples

The following example shows the output CSV file. In my tests, it was possible to retrieve information for up to 300 users, with each user being added to 10 security groups. Even when a user is registered in multiple security groups, all the information can be correctly obtained.

Input File Examples

Before explaining the script, let's prepare a CSV file like the one shown below. This CSV file will be used to search for the specified users in Azure AD and retrieve the associated security groups through loop processing. It's very simple.

Script Description

ここから先は

1,283字 / 1画像

¥ 300

この記事が気に入ったらサポートをしてみませんか?