PDF Creator | PDF Converter | PDF Software | Create PDF Send posts as PDF to


Connect to Exchange Online PowerShell

Connect to Exchange Online PowerShell

Postby Ernie » Fri Dec 30, 2016 4:55 pm

Applies to: Exchange Online

Remote PowerShell allows you to manage your Exchange Online settings from the command line. You use Windows PowerShell on your local computer to create a remote PowerShell session to Exchange Online. It’s a simple three-step process where you enter your Office 365 credentials, provide the required connection settings, and then import the Exchange Online cmdlets into your local Windows PowerShell session so that you can use them.

:!: Important: If you're an Exchange Online Protection (EOP) standalone customer, and you're using the service to protect on-premises mailboxes, use the connection instructions in the topic Connect to Exchange Online Protection using remote PowerShell. If your EOP subscription is Exchange Enterprise CAL with Services (includes data loss prevention (DLP) and reporting using web services), the connection instructions in this topic will work for you.

What do you need to know before you begin?

    • Estimated time to complete: 5 minutes
    • You can use the following versions of Windows:
      ◊ Windows 10
      ◊ 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 later and then either the Windows Management Framework 3.0 or the Windows Management Framework 4.0. For more information, see Installing the .NET Framework and Windows Management Framework 3.0 or Windows Management Framework 4.0.

    • Windows PowerShell needs to be configured to run scripts, and by default, it isn't. You get the following error when you try to connect:

    Files cannot be loaded because running scripts is disabled on this system. Provide a valid certificate with which to sign the files.

    To enable Windows PowerShell to run signed scripts, run the following command in an elevated Windows PowerShell window (a Windows PowerShell window you open by selecting Run as administrator):

    Code: Select all
    Set-ExecutionPolicy RemoteSigned

    You need to configure this setting only once on your computer, not every time you connect.

    • For information about keyboard shortcuts that may apply to the procedures in this topic, see Keyboard shortcuts in the Exchange admin center.
:N: Tip: Having problems? Ask for help in the Exchange forums. Visit the forums at: Exchange Server, Exchange Online, or Exchange Online Protection.

Connect to Exchange Online

    1. On your local computer, open Windows PowerShell and run the following command.

    Code: Select all
    $UserCredential = Get-Credential

    In the Windows PowerShell Credential Request dialog box, type your Office 365 user name and password, and then click OK.

    2. Run the following command.

    Code: Select all
    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection

    :N: Note: If you are an Office 365 operated by 21Vianet customer in China, use the following value for the ConnectionUri parameter: https://partner.outlook.cn/PowerShell.

    3. Run the following command.

    Code: Select all
    Import-PSSession $Session

    :N: Note: Be sure to disconnect the remote PowerShell session when you're finished. If you close the Windows PowerShell window without disconnecting the session, you could use up all the remote PowerShell sessions available to you, and you'll need to wait for the sessions to expire. To disconnect the remote PowerShell session, run the following command.

    Code: Select all
    Remove-PSSession $Session

How do you know this worked?

    After Step 3, the Exchange Online cmdlets are imported into your local Windows PowerShell session and 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 user name 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.

      • The account you use to connect to Exchange Online must be enabled for remote PowerShell. For more information, see Enable or disable access to Exchange Online PowerShell.

      • TCP port 80 traffic needs to be open between your local computer and Office 365. It's probably open, but it’s something to consider if your organization has a restrictive Internet access policy.

Site Administrator
User avatar

i'm still here

Site Admin
Site Admin
Posts: 206
Joined: Sat Nov 22, 2008 5:32 pm
Location: New Jersey
Highscores: 20
WordPress Blog: Visit User's Blog


Similar topics

Return to Office 365

Who is online

Users browsing this forum: No registered users and 0 guests