Connect to Exchange Online PowerShell

PowerShell

Set-ExecutionPolicy RemoteSigned
winrm get winrm/config/client/auth

If you don’t see the value Basic = true, you need to run this command to enable basic authentication for WinRM:

winrm set winrm/config/client/auth @{Basic="true"}

If basic authentication is disabled, you’ll get this error when you try to connect:The WinRM client cannot process the request. Basic authentication
is currently disabled in the client configuration. Change the client
configuration and try the request again.

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

PowerShell

 

  • $UserCredential = Get-Credential
    

    In the Windows PowerShell Credential Request dialog box, type your work or school account and password, and then click OK.

  • Run the following command:
    PowerShell
  • $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
    

    Notes:

    • For Office 365 operated by 21Vianet, use the ConnectionUri value: https://partner.outlook.cn/PowerShell
    • For Office 365 Germany, use the ConnectionUri value: https://outlook.office.de/powershell-liveid/
    • For Office 365 Government Community Cloud High (GCC High), use the ConnectionUri value: https://outlook.office365.us/powershell-liveid/
    • If you’re behind a proxy server, run this command first: $ProxyOptions = New-PSSessionOption -ProxyAccessType <Value>, where the ProxyAccessType value is IEConfig, WinHttpConfig, or AutoDetect.

      Then, add the following parameter and value to the end of the $Session = … command: -SessionOption $ProxyOptions.

      For more information, see New-PSSessionOption.

  • Run the following command:
    PowerShell

 

Import-PSSession $Session -DisableNameChecking

Notitie

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.

PowerShell
Remove-PSSession $Session
Close Menu