You’re trying to manage Office 365 mailboxes and you receive the below error message:
This error message means that the Exchange Module for PowerShell is not loaded and therefore the command “get-mailbox” is not recognized.
To manage Exchange Online mailboxes in Office 365 with PowerShell you must connect your PowerShell session with Exchange Online. This is done via the following commands:
- $Credentials = Get-Credential
- $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $Credentials -Authentication Basic -AllowRedirection
- Import-PSSession $Session -DisableNameChecking
1. Establish the credentials you will use to connect with Exchange Online.
2. Establish a session with Exchange Online.
3. Import the session into your PowerShell console
The output from the above commands will be similar to this:
And this means you’re ready to perform all the magic PowerShell tricks in your Exchange Online environment!
Finally – you may be wondering what commands are available in the Exchange Online module. Use the following command to list all of them (replace the module name with the name you received in the previous output):