[Update]: Post updated on January 27, 2023.
Microsoft 365 web interface was designed to make it easier to manage your tenant right down to its administrative bowels. On the one hand it really is quick and simple to navigate, on the other it definitely lacks some advanced configuration options so loved by sysadmins.
Luckily there is the mighty PowerShell coming to the rescue! You should already know its potential, which can also be utilized in Microsoft 365. Find out how.
System Requirements
To remotely manage Microsoft 365 with PowerShell your machine must meet the following requirements:
- Operating system: Windows 8* (or later), or Windows Server 2012 (or later).
- Microsoft .NET Framework 4.5
- Microsoft Management Framework 3.0, 4.0, or 5.1
- Exchange Online PowerShell V3 Module. Learn more about deprecation of the V2 module
*Windows 7 or Windows Server 2008 should still work if you meet the rest of requirements, but since both systems have reached the end of extended support period, they are no longer officially supported.
Once you have all the components installed you are ready to connect to Exchange Online in your Microsoft 365 tenant.
Connecting to Exchange Online with PowerShell
First, you need to make sure your PowerShell console is allowed to run scripts. Run PowerShell and check your Execution policy with:
Get-Execution-Policy
If the policy is set to Restricted, run the following cmdlet:
Set-ExecutionPolicy RemoteSigned
Now, to connect to Exchange Online, run:
Connect-ExchangeOnline
Next, insert your credentials in the standard Microsoft 365 login window. And that’s it! You are now ready to run PowerShell commands.
When you are done, it’s always recommended to run:
Disconnect-ExchangeOnline
Below, you can find the the login process in one script, which you can save to the PS1 file. Mind that this script will not work for MFA-enabled accounts (you need to use the plain Connect-ExchangeOnline cmdlet for accounts with MFA).
Set-ExecutionPolicy RemoteSigned; $365Logon = get-credential; Connect-ExchangeOnline -Credential $365Logon
Whenever you need to remotely administer your Office 365 with PowerShell, simply run the PS1 script with the code above. Alternatively, you can add it to your PowerShell profile. That way, you will be automatically connected with your Exchange Online organization after launching PS or PowerShell ISE.
To learn about available Exchange Online cmdlets, see this Microsoft article.
Delegate selected Microsoft 365 management duties to non-IT staff
Let your Marketing team manage Office 365 email signatures (CodeTwo Email Signatures)
Hi,
Thanks for this post. Just wonder if its possible to export mailboxes to pst using this connection method…
Best Regards
Hi Mick,
No. At the moment you can only export Office 365 mailboxes to PST using Discovery tools.
Refer to this article for more info: https://www.codetwo.com/admins-blog/how-to-export-office-365-mailboxes-to-pst-using-ediscovery/?sts=4156
Best regards,
Adam