In order to start using PowerShell for Office365 Admin tasks, you need to following :

Or you can also install the module directly from PowerShell as follow:

Install-Module MSOnline
  • You need to have Office365 Administrator Rights.
  • A 64-bit machine
  • At least Windows 7 SP1+ or Windows Server 2008R2+


Once you have installed the pre-requisites, you need to

1- Import the module into PowerShell

For this, simply type:

Import-Module MSOnline

2- Get Connection Credentials

In order to create a credential object, we can do:

$cred= Get-Credential

Once you run this command, you will be prompted to enter your username and password. Please be aware that at this stage there is no validation of the username and password.

3- Establish Connection

Now, to connect to your tenant, just type:

Connect-MsolService -Credential $cred

Note that we pass the $cred object which contains the username and password supplied in the previous step.

If the connection is successful, you won’t see any output.

4- List all users in your tenant

In order to test that we are properly connected to our tenant, we can simply list all the users by doing :


Which will output a table of PrincipalName, DisplayName and isLicensed boolean.

Show Buttons
Hide Buttons

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.