Connect to Office 365 Security & Compliance Center PowerShell

 

Topic Last Modified: 2017-07-10

Learn how to connect to Security & Compliance Center PowerShell.

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

noteNote:
For some features (for example, mailbox archiving), the Security & Compliance Center links to existing functionality in the Exchange admin center. To use PowerShell with these features, you need to connect to Exchange Online instead of the Security & Compliance Center. For more information, see Connect to Exchange Online Protection PowerShell.

For more information about the Security & Compliance Center, see Office 365 Security & Compliance Center.

  • Estimated time to complete: 5 minutes

  • Office 365 global admins have access to the Security & Compliance Center, but everyone else needs to have their access configured for them. For details, see Give users access to the Office 365 Security & Compliance Center.

  • You can use the following versions of Windows:

    • Windows 10

    • Windows 8.1

    • Windows Server 2016

    • 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):

    Set-ExecutionPolicy RemoteSigned
    

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

  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 work or school account and password, and then click OK.

  2. Run the following command.

    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
    

    Note:   For Office 365 Germany, use the ConnectionUri value: https://ps.compliance.protection.outlook.de/powershell-liveid/

  3. Run the following command.

    Import-PSSession $Session
    
noteNote:
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.
Remove-PSSession $Session

After Step 3, the Security & Compliance Center 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 a Security & Compliance Center cmdlet, for example, Get-HoldCompliancePolicy, 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.

  • Verify that your account has permission to access the Security & Compliance Center. For details, see Give users access to the Office 365 Security & Compliance Center.

  • To help prevent denial-of-service (DoS) attacks, you're limited to three open remote PowerShell connections to the Security & Compliance Center.

  • 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.

The cmdlets that you use in this topic are Windows PowerShell cmdlets. For more information about these cmdlets, see the following topics.

 
Show: