Skip to content
Menu
Tech Automation Blog
  • About Author
  • Contact
Tech Automation Blog

List all Azure AD groups

Posted on August 19, 2019February 27, 2022

Update : updated script to support Azure Az powershell module.

In previous post, I provided a script to generate a CSV report of Azure AD users. Here is a Powershell script to generate a report on Azure Active Directory (AD) Groups in Azure tenant. This csv file report with information of all Azure AD groups. It includes a list of all standard properties you need to know for a group. For more details refer Microsoft documentation.

Again, I run this script just to have a quick and easy report of Azure AD to present to my management or auditors. To run this script, you need login to Azure Account and make sure you have Azure Resource Manager Powershell module installed and imported. Please refer Microsoft documentation on how to install Powershell AzureRM module on your system. Let me know if this is helpful!

$currentDir = $(Get-Location).Path
$oFile = "$($currentDir)\AzureADGroups_Details.csv"

if(Test-Path $oFile){Remove-Item $oFile -Force}
"DisplayName,ObjectId,MailEnabled,Mail,MailNickName,OnPremisesSecurityIdentifier,SecurityEnabled,DirSyncEnabled,LastDirSyncTime,LastDirSyncTime" | Out-File $oFile -Append -Encoding ASCII
Get-AzureADGroup -All $true | ForEach-Object{
    $DisplayName = $ObjectId = $MailEnabled = $Mail = $MailNickName = $OnPremisesSecurityIdentifier = ""
    $SecurityEnabled = $DirSyncEnabled = $LastDirSyncTime = ""
	$DisplayName = $_.DisplayName.split(",")[0]
    $ObjectId = $_.ObjectId
    $MailEnabled = $_.MailEnabled
    $Mail = $_.Mail
    $MailNickName = $_.MailNickName
    $OnPremisesSecurityIdentifier = $_.OnPremisesSecurityIdentifier
    $SecurityEnabled = $_.SecurityEnabled
    $DirSyncEnabled = $_.DirSyncEnabled
    $LastDirSyncTime = $_.LastDirSyncTime
	"$DisplayName,$ObjectId,$MailEnabled,$Mail,$MailNickName,$OnPremisesSecurityIdentifier,$SecurityEnabled,$DirSyncEnabled,$LastDirSyncTime,$LastDirSyncTime" | Out-File $oFile -Append -Encoding ASCII
}

Download above script and save it with a .ps1 file extension. Open powershell console and, connect to your Azure AD account using – Connect-AzureAD. It will prompt you to enter your Azure credentials.

Connect to Azure AD Account

After you login to Azure, run the powershell script saved in previous step.

Run Powershell script

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on LinkedIn (Opens in new window) LinkedIn
May 2025
M T W T F S S
 1234
567891011
12131415161718
19202122232425
262728293031  
« May    

Recent Posts

  • Monitor and alert Azure Service Health issues May 5, 2020
  • AWS IAM User access review May 3, 2020
  • Integrate Azure Security Center with Event Hub April 28, 2020
  • Add Tags to Azure Subscription April 24, 2020
  • Automate Azure billing report in Excel March 6, 2020

Categories

©2025 Tech Automation Blog | Powered by SuperbThemes