×
Steps to Remove Azure Active Directory Users and Groups
Blog Cloud Computing

Steps to Remove Azure Active Directory Users and Groups

Steps to Remove Azure Active Directory Users and Groups

In this blog, We will show you the Steps to Remove Azure Active Directory Users and Groups using Windows PowerShell.

 

REQUIREMENTS

  • Microsoft Azure Subscriptions
  • Windows VM

 

OVERVIEW

  • We have already installed Active Directory Domain named azdomain.local and created three users for the demo purpose.

Steps to Remove Azure Active Directory Users and Groups

 

  • Also, we have synchronized the local Active Directory users with Azure AD.

Steps to Remove Azure Active Directory Users and Groups

 

  • We can not delete the AD users from the Azure portal. Delete user option will be greyed out.

Steps to Remove Azure Active Directory Users and Groups

 

EXPORTING AZURE AD USERS AND GROUPS

  • Open the PowerShell window and connect to the Azure Active Directory using Global administrator account using below command.

connect-msolservice

Steps to Remove Azure Active Directory Users and Groups

 

  • Provide the global admin ID from the pop-up screen and click Next.

Steps to Remove Azure Active Directory Users and Groups

 

  • Enter the Password and click Sign in.

Steps to Remove Azure Active Directory Users and Groups

 

  • After successful login, export the Azure AD user into a CSV file using the below command.

Get-MsolUser –All | Export-CSV C:\ADusers.csv

Steps to Remove Azure Active Directory Users and Groups

 

  • The file ADusers.csv will be available on C: drive.

Steps to Remove Azure Active Directory Users and Groups

 

  • Export the Azure AD Groups into a CSV file using the below command.

Get-MsolGroup –All | Export-CSV C:\ADGroups.csv

Steps to Remove Azure Active Directory Users and Groups

 

  • Open the ADusers.csv and remove the Global administrator account from the list.

Steps to Remove Azure Active Directory Users and Groups

 

  • Save and close the CSV file.

 

DELETE THE AD USERS AND GROUPS

  • From the PowerShell window, execute the below command to delete the AD users.

Import-CSV C:\ADusers.csv | Remove-MsOlUser –Force

Steps to Remove Azure Active Directory Users and Groups

 

  • Run the below command to delete the AD Groups.

Import-CSV C:\ADGroups.csv | Remove-MsOlGroup –Force

image

 

VERIFICATION

  • Open the Azure portal, and click on the Active Directory users and groups link.

Steps to Remove Azure Active Directory Users and Groups

 

  • Click on All users Link. Only the Global administrator account is available on the list.

Steps to Remove Azure Active Directory Users and Groups

 

  • There is no groups are available on the list.

Steps to Remove Azure Active Directory Users and Groups

 

VIDEO

Thanks for reading this blog. We hope it was useful for you to know the steps to delete the Azure Active Directory users using Powershell command.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.