How to Install and Connect to Azure AD with PowerShell?
Last Updated :
22 Nov, 2023
Azure Active Directory (Azure AD) is a service for managing identities and access in the cloud. This solution facilitates access to thousands of additional SaaS applications, the Azure portal, and external resources like Microsoft 365 for your staff members.
What is Azure Active Directory (AD)?
Azure Active Directory is simply known or called Azure AD. AD is a cloud-based identity and access management SaaS(Software as a Service) to manage user identities and access to applications across Azure services including third-party services. With Azure AD we can manage users and groups, create and manage access policies, and provide single sign-on (SSO) to applications.
What is Azure AD Module?
The Azure AD PowerShell module is a powerful tool that can be used to automate tasks in Azure AD. It can be used to manage users, groups, applications, and Azure AD settings directly from the PowerShell console. Let’s get started with the steps involved in installing and connect to Azure AD on Windows PowerShell.
Steps to Install And Connect to Azure AD With PowerShell
Here are the best practices for connecting to Azure AD with PowerShell, follow the below steps to Install and Connect to Azure AD using PowerShell on your Windows. To know how to install Azure Powershell on Windows refer to How To Install and Update Azure PowerShell on Windows Machine?
Step 1: To install the AzureAD PowerShell module, you need to open PowerShell in administrator mode.
.png)
Step 2: Next, run the following command to set the PowerShell execution policy to remote signed >> Select ‘Y’ to proceed.
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
.png)
Step 3: To Install the AzureAD module. Run the following command to install the Azure AD PowerShell module:
Install-Module AzureAD
This command will install the latest version of the AzureAD module.
.png)
Also read: How To Install and Update Azure PowerShell on Windows Machine?
Step 4: Once the module is installed, run the following azure powershell command to connect to Azure AD
Connect-AzureAD
This command will let to connect your Azure AD credentials. Enter your username and password, and then click Connect.
.png)
That’s it! Once you are connected to Azure AD, you can start using the Azure AD PowerShell cmdlets to manage your Azure AD tenant.
Optional: If you wish to update the module at any time then use the following command:
Update-Module -Name AzureAD
.png)
PowerShell Commands For Azure AD
- Connect-AzureAD (PowerShell cmdlet) which helps you connects Azure Active Directory with an authenticated account.
- Disconnect-AzureAD (PowerShell cmdlet) which lets you disconnect the current logged-in session from an Azure Active Directory.
- Get-AzureADDirectoryRole (PowerShell cmdlet) allows fetching the details of Azure Active Directory roles.
- Get-AzureADUser (PowerShell cmdlet) helps you to fetch the information of users in Azure Active Directory tenant
- Get-AzureADGroup (PowerShell cmdlet) helps you to fetch the information of Azure AD Group in the tenant.
To fetch the information or details of any Azure AD services, you require the Azure AD Administrator role or a custom AD role with the Service Read permission.
Clean Up or Uninstall AzureAD PowerShell Module from your Environment
To clean up the installed AzureAD module, you can use the following command to remove the AzureAD module package resources:
Uninstall-Module -Name AzureAD
If it is successfully removed, you won’t get any errors in the PowerShell terminal. To verify the removal of the module, you can use the following command:
Get-InstalledModule -Name AzureAD
or
Get-InstalledModule
Sample Output:

Similar Reads
How To Install and Update Azure PowerShell on Windows Machine?
Pre-requisite: Azure Azure PowerShell is a command-line tool that allows you to manage Azure resources from the command line. It is a powerful tool that can be used to automate tasks, provision resources, manage users and policies in Azure a,d also for troubleshooting problems. Actually, Azure Power
3 min read
How to Create Virtual Network in Azure using PowerShell ?
Microsoft Azure provides various resources and services to provide us with a scalable environment for development and testing processes. Azure provides a virtual machine service, which allows us to leverage the resources virtually. We may have more than one virtual machine as a resource, according t
9 min read
How To Deploy A Container To Azure Container Instances ?
In layman's terms, how will it feel when a developer develops an app and a member of the testing team tries to test the application on his/her OS? They will have to install the packages, and libraries required to run the app. Well, in this case, the container makes it easy and faster to rapidly depl
8 min read
How to Install Visual Studio Code in Azure Virtual
Visual Studio Code (VS Code) is a powerful, open-source code editor beloved by developers for its versatility, customization options, and extensive plugin ecosystem. But what if your development needs to extend to the cloud? Azure virtual machines provide a scalable and secure environment in which t
4 min read
Microsoft Azure - Connect to a Storage Account using Private Link
In this article we will learn how to securely connect to a Storage Account using private links. In this article, we are going to look into the new private link in the Azure Portal. And you could find that by searching. The good thing about the private link is that it allows your resources to communi
3 min read
How to Install MMA Agent for a Windows Virtual Machine using PowerShell?
Pre-requisite:- Azure Here in this article, we will show how to add or install MMA Agent on a Windows Virtual Machine in Azure using PowerShell. Before diving into the process let's know what an MMA agent is. MMA Stands for Microsoft Monitoring Agent can be configured to collect the performance logs
2 min read
How to Install OMS Agent for a Linux Virtual Machine using PowerShell?
Pre-requisite:- Azure Here in this article, we will show how to add or install OMS Agent on a Linux Virtual Machine in Azure using PowerShell. Before diving into the process let's know about what an OMS agent is. OMS Stands for Operations Management Suite Agent can be configured to collect the perfo
2 min read
Microsoft Azure - Create Resource Group with Tags using PowerShell
Pre-requisite: Microsoft Azure: Resource Tagging and Best Practices In this article, I am going to show you how to create resource groups with tags using PowerShell in Microsoft Azure from Azure Cloud Shell in simple easy steps. Let's get started. Prerequisite: Contributor Access on Subscription to
1 min read
How to Install SQL Server on Azure VM?
Microsoft Azure provides us with multiple database services which help us to run popular relational database management systems, like MySQL, SQL Server, and PostgreSQL in the cloud. We can use an SQL server on Azure Virtual machines by running a virtual machine in Azure and installing an SQL server
5 min read
How to Create App Service in Azure using Terraform
Azure App Service is a service that provides a managed platform for deploying applications in the Azure cloud. It supports multiple language applications. App service allows building, deploying and scaling of applications in Azure. Setting up an app service is a complicated process. let's see how we
5 min read