How to Connect to Azure Ad using PowerShell

If you are looking to perform Azure ad task using PowerShell then you need to know How to Connect to Azure Ad using PowerShell.

 

We will first have to install the Azure ad module on the PowerShell, following which it will allow to connect to Azure ad.

 

In this blog, we will get to know all the steps that is required to connect to Azure ad using PowerShell.

 

Steps to Connect to Azure Ad PowerShell:

Search and run the windows PowerShell on your windows computer, As an administrator:

 

search powershell

If its opened correctly as admin, it should look as shown in the below image:

 

powershell as admin

 

Once opened correctly, we will set the execution policy to remote signed, this will allow us to install and run the script on the PowerShell.

 

Run the command: Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

 

If prompted to install, type A and hit enter.

 

execution policy

 

After the execution policy is set we will install the Azure ad PowerShell module by running the command:

 

Install-Module AzureAD -Force

 

install module

 

The above command will force the installation of latest version of azure ad on your PowerShell.

 

We will then import the Azure Ad module, for that run the command: 

 

Import-Module AzureAD

 

import

 

Once the module is installed, you should be able to run the command to connect to Azure ad, to connect run the following command: 

 

Connect-AzureAD

 

Connect to Azure Ad using PowerShell

 

It will prompt to login with the admin account which has the respective Admin center access.

 

After you have signed in, you should see a message like this:

 

Connect to Azure Ad using PowerShell

 

You should be able to run Azure ad module commands in the PowerShell which is now connect to azure ad:

 

Get-AzureAduser

 

Connect to Azure Ad using PowerShell

 

Do let me know if you have any question. you can share the same in the comment section.

 

Useful links:

Connect to Exchange Online using PowerShell

Connect to Microsoft admin center using PowerShell

 

Date: 21/09/2023

Author: Prem

Leave a Comment

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