Using the PowerShell in Azure Active Directory to examine the accounts

MVP

 

Hi Azure friends,

 

I used the PowerShell ISE for this configuration. But you are also very welcome to use Visual Studio Code, just as you wish. Please start with the following steps to begin the deployment (the Hashtags are comments):

 

#The first two lines have nothing to do with the configuration, but make some space below in the blue part of the ISE

Set-Location C:\Temp
Clear-Host

 

#We need the cmdlets
Install-Module -Name AzureAD -AllowClobber -Force -Verbose

#Sometimes the module must be imported
Import-Module AzureAD

#Username and PW for Login
$Credential = Get-Credential

#Lets connect to the Azure Active Directory
Connect-AzureAD -Credential $Credential

#View all accounts
Get-AzureADUser

#View a specific account
Get-AzureADUser -ObjectID jane.ford@tomwechsler.xyz

#View additional property values for the cmdlet
Get-AzureADUser | Get-Member

#View additional property values for a specific account
Get-AzureADUser | Select DisplayName,Department,UsageLocation

#To see all the properties for a specific user account
Get-AzureADUser -ObjectID jane.ford@tomwechsler.xyz | Select *

#As another example, check the enabled status of a specific user account
Get-AzureADUser -ObjectID jane.ford@tomwechsler.xyz | Select DisplayName,UserPrincipalName,AccountEnabled

#View account synchronization status
Get-AzureADUser | Where {$_.DirSyncEnabled -eq $true}

#Find cloud-only accounts
Get-AzureADUser | Where {$_.DirSyncEnabled -ne $false}

#View accounts based on a common property
Get-AzureADUser | Where {$_.UsageLocation -eq $Null}

#List all accounts of users who live in London
Get-AzureADUser | Where {$_.City -eq "London"}
 
Now you have used the PowerShell to view Azure Active Directory Accounts! Congratulations!
 

I hope this article was useful. Best regards, Tom Wechsler

 

P.S. All scripts (#PowerShell, Azure CLI, #Terraform, #ARM) that I use can be found on github! https://github.com/tomwechsler

0 Replies