Azure services

Manage Azure Active Directory with PowerShell – Part 01

In this series of articles, it which will explain how to use PowerShell to manage your Azure Active Directory instance. In Part 01, I am going to show how to connect with Azure Active Directory using PowerShell and show actions of some day to day operation related commands.

In order to use PowerShell with Azure Active Directory, first we need to install Azure Active Directory Module in local computer. there is two version of Azure active directory PowerShell module. One was made for the Public Preview and the latest one released after announces Azure AD GA. You can download module from http://connect.microsoft.com/site1164/Downloads/DownloadDetails.aspx?DownloadID=59185

If you had the previous version installed, highly recommended to replace it with the new version.

Once installed let’s check its status.

Get-Module MSOnline

Azure Active Directory Powershell module

Azure Active Directory PowerShell Commands

In order to list down all the commands associate cmdlets with the module we can use

Get-Command -Module MSOnline

Azure Active Directory list of available PowerShell commands

Next step is to connect to Azure AD Instance. In order to do that we can use,

Connect-MsolService

 It will prompt for the login details. Please use your Azure DC Admin account details. Please note login via Microsoft account not supported.

First, we can list down all the domain under the given subscription. To do that we can use,

Get-MsolDomain

verify domain

As next steps I like to list down all the users in Azure AD Setup.

Get-MsolUser

Get user details

It will list down all the Users in the Azure AD.

I also can search for a specific user based on text patterns. In below example I am searching users with Name which match text “Dishan”

Get-MsolUser -SearchString “Dishan”

Idea of my search is to find some object values for this user. I can combine above command to return all the object value.

Get-MsolUser -SearchString “Dishan” | Select-Object *

user object details

Now we know what are the objects been use and I can make more unique search.

Get-MsolUser | Select-Object DisplayName,whenCreated,LastPasswordChangeTimestamp

Above command will list me all the users with Display Name, Date and Time It was created, and Date and Time of Last Password Change Action.

last password change

Get-MsolUserRole another handy cmdlet. It can use to check the role of a user account.

Get-MsolUserRole -UserPrincipalName “dcadmin@REBELADMIN.onmicrosoft.com” | fl

 The above command will find the role for the given user account.

role of account

 Get-MsolGroup cmdlet can use to list, filter Groups in the Azure AD.

group details

Using searchstring can search for the groups based on text patterns.

Get-MsolGroup -SearchString “AAD”

search for group

Get-MsolGroupMember can use to list down the members in the group.

Get-MsolGroupMember -GroupObjectId “77a76005-02df-48d5-af63-91a19ed55a82”

list group members

Remove-MsolUser cmdlet can use to remove the user object from the Azure AD. This can combine with searchstring to search for user and then remove the object same time.

Get-MsolUser -SearchString “user2” | Remove-MsolUser

 Above command will search for the user object which have display name similar to user2 and then delete it.

remove user account

In next post let’s dig further in to cmdlets which can use to manage Azure AD.

If there is any question, please feel free to contact me on rebeladm@live.com

Related posts
Azure servicesMicrosoft Entra IDMicrosoft Technologies

Step-by-Step Guide: Configure Entra ID lifecycle workflow to trigger mover task on user profile changes

The Entra ID lifecycle workflow is a feature of Microsoft Entra ID identity governance and Microsoft…
Read more
Azure servicesCyber SecurityMicrosoft Entra IDMicrosoft Technologies

Microsoft Entra Permissions Management – Part 01 – How to onboard Azure Subscription ?

Today’s rapidly changing digital landscape creates new identity and access challenges. Microsoft…
Read more
Azure servicesMicrosoft Entra IDMicrosoft Technologies

Step-by-Step Guide : How to Automate JML process with Microsoft Entra lifecycle workflows ?

JML (Joiners/Movers/Leavers) process of an organization has a major impact on its security and…
Read more
Newsletter
Become a Trendsetter

Sign up and get the best of RebelAdmin, tailored for you.

Leave a Reply

Your email address will not be published. Required fields are marked *