Share via


Updated: July 30, 2015

Applies To: Azure, Office 365, Windows Intune


  • The cmdlets were previously known as the Microsoft Online Services Module for Windows PowerShell cmdlets.

The Connect-MsolService cmdlet will attempt to initiate a connection with Microsoft Azure Active Directory. The caller must provide their credential through a PSCredential object.


This cmdlet may return a warning or error if the version of the module is out of date.


Connect-MsolService [-Credential <PSCredential>] [<CommonParameters>]


    -Credential <PSCredential>
        The credential to use for connecting to Office 365.
        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        "get-help about_commonparameters".


There are a couple of ways that you can connect to the online service. The first is to simply run the cmdlet and you will be prompted for credentials. The second is to supply the credentials as a variable ($cred is used below) and then specify that variable when connecting. The following examples demonstrate further.

Example 1: Initiate a connection to the default service

This command attempts to initiate a connection. Since no credential is provided, the user is prompted to enter a username and password.


Example 2: Initiate a connection to the specified MSOL Service

This command attempts to initiate a connection to AzureChinaCloud with Microsoft Azure Active Directory using the credential provided previously provided as $Cred. The credential must be of the type PSCredential, which is typically retrieved through the Get-Credential cmdlet.

Connect-MsolService -Credential $Cred -AzureEnvironment AzureChinaCloud

Additional Resources

There are several other places you can get more information and help. These include:

See Also

Other Resources

Manage Azure Active Directory by using Windows PowerShell