Learn How to Connect to Microsoft Office 365 with PowerShell
In this article, you will learn the steps how you can connect to Microsoft Office 365 with PowerShell. You need to install the Microsoft .NET Framework 4.5 or 4.5.1 and then either the Windows Management Framework 3.0 or the Windows Management Framework 4
Connect to Exchange Online(Office 365)
1. On your local computer, open Windows PowerShell and run the following command.
$UserCredential = Get-Credential
In the Windows PowerShell Credential Request dialog box, type your Exchange Online username and password, and then click OK.
2. Run the following command.
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic –AllowRedirection
- Disconnect the remote PowerShell session
After Step 3, the Exchange Online cmdlets are imported into your local Windows PowerShell session as tracked by a progress bar. If you don’t receive any errors, you connected successfully. A quick test is to run an Exchange Online cmdlet—for example, Get-Mailbox—and see the results.
If you receive errors, check the following requirements:
A common problem is an incorrect password. Run the three steps again and pay close attention to the username and password you enter in Step 1.
- To help prevent denial-of-service (DoS) attacks, you're limited to three open remote PowerShell connections to your Exchange Online organization.
- Windows PowerShell needs to be configured to run scripts. You only need to configure this setting once on your computer, not every time you connect. To enable Windows PowerShell to run signed scripts, run the following command in an elevated Windows PowerShell window (a Windows PowerShell window you opened by selecting Run as administrator).
- The account you use to connect to Exchange Online must be enabled for remote Shell. For more information, see Manage remote PowerShell access in Exchange Online.
- TCP port 80 traffic needs to be open between your local computer and Exchange Online. It's probably open, but it’s something to consider if your organization has a restrictive Internet access policy.
You can use the following versions of Windows to work on Powershell.
- Windows 8 or Windows 8.1
- Windows Server 2012 or Windows Server 2012 R2
- Windows 7 Service Pack 1 (SP1)*
- Windows Server 2008 R2 SP1*
You need to install the Microsoft .NET Framework 4.5 or 4.5.1 and then either the Windows Management Framework 3.0 or the Windows Management Framework 4.0. For more information, see Installing the .NET Framework 4.5, 4.5.1 and Windows Management Framework 3.0 or Windows Management Framework 4.0.
Check out the list of all other articles:
- Learn How to Lookup With Variable Sheet Name in Microsoft Excel
- Learn How to Lookup Value Between Two Numbers in Microsoft Excel
- Learn How to Lookup Up Cost for Product or Service in Microsoft Excel
- Learn How to Lookup Lowest Value in Microsoft Excel
- Learn How to Lookup Lowest Sunday Tide in Microsoft Excel
- Learn How to Lookup Latest Price in Microsoft Excel
- Learn How to Lookup Last File Version in Microsoft Excel
- Learn How to Lookup Entire Row in Microsoft Excel