-->

May 22, 2018

Connecting To AzureAD With PowerShell

Use PowerShell To Connect To AzureAD


If you already have one of the following required releases installed:


Then, you won't need the PowerShellGet module (available here) as it is included into the above releases. If one of these releases are not installed, follow the steps using the above link to install the module.

Afterwards, we will install Azure Active Directory V2 PowerShell Module (hosted on the PowerShell gallery) because Office 365 uses this cloud-based user-authentication service to store users.

To do that, open Powershell as an administrator and run the following cmdlet:

Install-Module -Name AzureAD

You should get the following warning as described below:

Azure Active Directory V2 PowerShell Module

Enter "Yes" to proceed with the installation and enter the next PowerShell cmdlet:

$cred = Get-Credential

You will be prompted to type your credentials and they will be saved into the variable "$cred" as shown below:

Get-credential

Run the Connect-AzureAD PowerShell cmdlet and give the -Credential parameter with the variable $cred create previously.
Please note that entering a tenant name is not mandatory as Azure AD will automatically connect your tenant on the email address.

If you use MFA (Multi Factor Authentication) to connect to Azure Active Directory, run Connect-AzureAD without the -Credential parameter.

You are now connected to Azure Ad and you can now run PowerShell cmdlets.
For example, Get-AzureADUser (return all the user including external ones), Get-AzureADUser | where {$_.department -eq "Finance"} (display the properties of a user), etc...

Hope this tutorial will help solve issues related to Microsoft Azure Active Directory.



Leaving a review only takes 30 seconds and i appreciate it so much!

5 comments:

  1. Nice Article,

    Is your PST file corrupt? Looking for a solution to fix and recover damaged and corrupt files? If you are getting these issues then we suggest you download the Microsoft Scanpst Software.

    Thanks again...

    ReplyDelete
  2. Thank you for your the valuable information.

    ReplyDelete