Connect PowerShell to Exchange Online
What’s Exchange Online?
Exchange Online is Microsoft’s hosted email for businesses. It’s the industry-leading cloud solution adopted by small businesses and fortune 500 companies. Microsoft Exchange Online provides the benefits of a cloud-based email service with the robust capabilities of an on-premises server deployment. Simply put, Microsoft will store, manage, and secure your businesses email for a low monthly cost. If you don’t find Exchange Online click here to view the Office 365 plans.
“Windows PowerShell is a Windows command-line shell designed especially for system administrators. Windows PowerShell includes an interactive prompt and a scripting environment that can be used independently or in combination.
Unlike most shells, which accept and return text, Windows PowerShell is built on top of the .NET Framework common language runtime (CLR) and the .NET Framework, and accepts and returns .NET Framework objects. This fundamental change in the environment brings entirely new tools and methods to the management and configuration of Windows.”
PowerShell can be accessed on most modern Windows computers by using the taskbar and searching for PowerShell.
What’s Exchange Online’s PowerShell?
Office 365 is a suite of clouds and services bundled into one package. Connecting to Exchange Online’s PowerShell will allow you to manage the email portion of your Office 365 tenant. You’ll need to connect to a different cloud service to access other portions of your Office 365 tenant.
- To require all PowerShell scripts that you download from the internet are signed by a trusted publisher, run the following command in an elevated Windows PowerShell window (a Windows PowerShell window you open by selecting Run as administrator):
2. Download the following script: Connect-ExchangeOnline.
3. Unblock the script by right-clicking and clicking Unblock > Apply.
How to Connect to Exchange Online PowerShell
The script can be ran two different ways. You can run the script with the username and password directly inline or run the script without parameters and the PowerShell script will prompt for username and password.
Option 1: Run script with username and password inline
.\Connect-ExchangeOnline.ps1 AdminUser@domain.com AdminPassword123
Option 2: Run script with username and password prompt
How to Disconnect from Exchange Online PowerShell
To disconnect the session you can close the PowerShell window and the session will expire or run the script with the disconnect switch.
You’re now connected and can manage Exchange Online using PowerShell. The script will import the commands you can run. Microsoft has great documentation for each command. The easiest way to find the commands is Google.
For example, to get the mailboxes you run the following:
Follow me on Medium for more Office 365 information.