Open an elevated Windows PowerShell command prompt (run Windows PowerShell as an administrator).

In the Administrator: Windows PowerShell command window, run this command:

Install-Module -Name AzureAD

To connect to Azure AD for your Office 365 subscription with an account name and password or with multi-factor authentication (MFA), run one of these commands from a Windows PowerShell command prompt (it does not have to be elevated).
Table 1

Office 365 cloud Command Office 365 Worldwide (+GCC) Connect-AzureAD

Connect-AzureAD

Run the Install-Module MSOnline command.
If prompted to install the NuGet provider, type Y and press ENTER.
If prompted to install the module from PSGallery, type Y and press ENTER

Step 2: Connect to Azure AD for your Office 365 subscription

To connect to Azure AD for your Office 365 subscription with an account name and password or with multi-factor authentication (MFA), run one of these commands from a Windows PowerShell command prompt (it does not have to be elevated).
Table 2

Office 365 cloud Command
Office 365 Worldwide (+GCC) Connect-MsolService

View all accounts

To display the full list of user accounts, run this command:

Get-AzureADUser

View a specific account

To display a specific user account, fill in the sign-in account name of the user account, also known as the user principal name (UPN), remove the "<" and ">" characters, and run this command:
PowerShell

Get-AzureADUser -ObjectID <sign-in name of the user account>

Here is an example:

Get-AzureADUser -ObjectID [email protected]