How to Install MSOnline Module and Connect Azure AD of 21Vianet China Cloud using PowerShell

Installing MSOnline is pretty Simple.

Open PowerShell in Elevated Mode and run the command,

Set-ExecutionPolicy -ExecutionPolicy unrestricted

Install-Modue -Name MSOnline

By Default, When you run the command

Connect-MsolService

You will get connected to Global Tenant ( Public Cloud)

What if you have 21Vianet operated Office 365 Azure Active Directory using PowerShell. You can use below command to connect AzureChinaCloud

Connect-MsolService -AzureEnvironment AzureChinaCloud

Enter Username(UPN),

Once you have entered password and credentials are validated, you will get MSOnline Module loaded.

Once Connected to 21Vianet Azure AD, You can validate by running the command

Get-MsolDomain

What is AzureEnvironment?

Microsoft Hosts Office 365 Cloud for Global(for Public), US Government, German and China. hence connecting the PowerShell also needs to be done for respective Azure Cloud.

If you want to connect other Azure Cloud Environments, Still you will be able to connect using Single MSOnline PowerShell Module using your respective Cloud Environment. Replace the AzureEnvironment based on your respective Azure Cloud to connect,

AzureChinaCloud
AzureGermanCloud
AzureGlobalCloud
AzureUSGovernment