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
Once you have installed the pre-requisites, you need to
For this, simply type:
Import-Module MSOnline
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.
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.
In order to test that we are properly connected to our tenant, we can simply list all the users by doing :
Get-MsolUser
Which will output a table of PrincipalName, DisplayName and isLicensed boolean.