# Microsoft Exchange – Connecting to remote server failed with the following error message

Connecting to Microsoft Exchange via PowerShell is a standard administrative tasks since Exchange 2007 was released. It’s available in all…

blog

26 Nov 2015 pl

![Microsoft Exchange – Connecting to remote server failed with the following error message](/wp-content/uploads/2016/01/MicrosoftExchange.png)

Connecting to **Microsoft Exchange** via **PowerShell** is a standard administrative tasks since **Exchange 2007** was released. It's available in all Exchange editions **Exchange 2007, Exchange 2010, Exchange 2013,** **Exchange 2016** and last but not least **Microsoft Office 365. **To properly manage **Exchange** you simply need the **PowerShell** connectivity. While using **PowerShell** locally doesn't do much checks, during remote connection a lot more things gets checked. One of which are **certificates**.

### ❗ Problem Description

During establishing remote connection to Exchange PowerShell using **New-PsSession** following error is received:

> [ERROR] New-PSSession : [mail1.domain.local] Connecting to remote server mail1.domain.local failed with the following error message : The server certificate on the destination computer (mail1.domain.loca:443) has the following errors: [ERROR] The SSL certificate contains a common name (CN) that does not match the hostname. For more information, see the about_Remote_Troubleshooting Help topic.

Another error that can show up during PowerShell connectivity:

> [ERROR] New-PSSession : [mail1.domain.local] Connecting to remote servermail1.domain.local failed with the following error message : The server certificate on the destination computer (mail1.domain.local:443) has the following errors: [ERROR] The SSL certificate could not be checked for revocation. The server used to check for revocation might be unreachable. [ERROR] For more information, see the about_Remote_Troubleshooting Help topic.

### 📧 Solution

While you should always use proper certificates on your servers that's not always the case. If you are sure about the server you're connecting to you can use **New-PSSessionOption **as part of **New-PSSession** connectivity.

```plain
$sessionOption = New-PSSessionOption -SkipRevocationCheck -SkipCACheck -SkipCNCheck

$EXOSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri $URL -Credential $Credentials -Authentication $Authentication -AllowRedirection -Name $sessionName -SessionOption $sessionOption
```

As you can you see in the example above there are 3 very useful switches for **New-PSSessionOption:**** SkipRevocationCheck, SkipCACheck, SkipCNCheck. **Those are in case you get other similar errors when connecting to PowerShell remotely and should solve most of the certificates issues that may arise during connection to powershell. Just make sure the server is trusted. Finally proceed with standard **Import-PSSession $EXOSession -AllowClobber**.

## Powiązane projekty

Projekty powiązane z tagami, kategoriami i treścią tego wpisu.

[Wszystkie projekty](/projekty/)

Trwa dopasowywanie projektów...

[Powrót do bloga](/blog/)

## Powiązane wpisy

- [Check an API write after a PowerShell timeout](/blog/verify-uncertain-api-outcomes-powershell/)
- [Inspect and convert mixed Office archives with PSWriteOffice](/blog/inspect-and-convert-mixed-office-archives-pswriteoffice/)
- [Compose PDF reports and automate page workflows with PSWriteOffice](/blog/automate-pdf-reports-and-page-workflows-pswriteoffice/)

<!-- PowerForge markdown artifact sha256:C0B39B4F810AE752C47034AF3331535618060C2F13556ADA77E34E40FDA1E408 -->
