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
Microsoft Azure - Working with PowerShell in Cosmos DB Azure Cosmos DB is a fully managed NoSQL database for build applications designed by Microsoft. It is highly responsive, scalable, and fully automated. Azure Cloud Shell is an in-browser terminal used to manage cloud instances in Azure. The PowerShell is an application used for the same purpose but
3 min read
How To Add Admin Rights to User for Windows Server in Microsoft Azure? Pre-requisite: Azure Azure is a cloud computing platform and service created by Microsoft. It provides a wide range of services that can be used to build, deploy, and manage applications and services through a global network of Microsoft-managed data centers. These services include virtual machines,
2 min read
Point-to-Site VPN Connection in Azure A Point-to-Site VPN connection allows individual clients to securely connect to the Azure virtual network. P2S connection can use one of the following protocols - OpenVPN ProtocolSecure Socket Tunneling ProtocolIKEv2 VPNAzure offers 3 ways to authenticate a client trying to connect to the virtual ne
3 min read
Microsoft Azure - RDP to Azure Virtual Machines using Azure Bastion In this article, we will learn how to do RDP(Remote Desktop Protocol) / SSH(Secure Shell) Connection to an Azure VM using Azure Bastion. First, let's discuss Azure Bastion. The Azure Bastion service is a fully platform-managed PaaS service that you provision inside your virtual network. It provides
3 min read
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
Microsoft Azure - Using PowerShell Core on Linux PowerShell Core on Linux is now integrated into Azure Cloud Shell. PowerShell used to be only available on Windows. Now, with PowerShell Core, it is cross-platform and runs on macOS and lots of Linux distributions like Ubuntu and Red Hat on ARM-Based platforms and even on Windows. This allows you to
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 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
Microsoft Azure - Install Azure Command Line Interface (Azure CLI) Azure CLI is a very powerful tool that can be used to automate tasks, create, update, manage or delete azure resources or to troubleshoot problems with az module cmdlets. By installing az modules on your system or on your development system you and your development team can easily create, update or
4 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