PowerShell in Exchange Server is a powerful tool for system admins and Exchange Server administrators. Although most of the things can be done via the graphical interface of the Exchange Admin Center (EAC), PowerShell allows to automate and run queries in bulk.
While performing a simple command using PowerShell in the Exchange Management Shell (EMS), you may face the below error. This error occurs when trying to connect to the Exchange Server.
Connecting to remote server exchange.contoso.com failed with the following error message: WinRM cannot complete the operation. Verify that the specified computer name is valid, that the computer is accessible over the network, and that a firewall exception for the WinRM service is enabled and allows access from this computer. By default, the WinRM firewall exception for public profiles limits access to remote computers within the same local subnet. For more information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:1
+ New-PSSession -ConnectionURI "$connectionUri" -ConfigurationName Micr ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : WinRMOperationTimeout,PSSessionOpenFailed
- You can start off the troubleshooting by checking the services mentioned in the error message. If you are running the Exchange Management Shell (EMS) from a remote computer, it is suggested you launch the application from the actual server to make sure that the issue is with the remote connectivity or on the server.
- If the management shell is still not working, even on the server itself, it’s best to check that all services are running. All the services which are set as Automatic or Automatic (Delayed start) should be started.
- Now check if WinRM is running. This can be done by running the following command from Command or PowerShell prompt with administrative privileges.
WinRM quickconfig
WinRM service is already running on this machine.
WinRM is not set up to allow remote access to this machine for management.
- If WinRM is running, it means everything is working fine. You can relaunch the Exchange Management Shell (EMS) and see if you connect with no issues.
- Another thing you can do to identify the culprit of the issue is to trace back what changed from when it was working to when it stopped. You can keep a log of all the changes being done on the server. It helps identify what went wrong and resolve the issue. Sometimes, the issue may occur due to a particular update or cumulative update (CU), installation of a third-party application, antivirus installation or changes to the configuration, changes to the firewall/ network, configurations, or add-ins to the software installed. You can check the log to investigate and roll back the changes that might have affected the WinRM or the installation integrity of the Exchange Server.
Wrapping Up
Now, if the problem still persists, it would mean that there might be corruption in the installation of the Exchange Server. In such a case, you would need to re-install the affected Exchange Server and recover the mailboxes. For this, it would be best to rely on a third-party tool that would simplify the operation. One such tool is Stellar Repair for Exchange which can do the job efficiently and with no extra resources. The tool can open any version of the Exchange Server database from 2007 to 2019 with minimal effort and from anywhere. It can also open corrupted databases with the Dirty Shutdown state. You don’t need an Exchange Server to open and browse through your database. You can use this application to granularly export the recovered mailboxes to PST and other formats. You can easily export public folders as well.
Stellar Repair for Exchange also allows you to export directly to a live Exchange Server of any version and an Office 365 tenant. It offers several features, like parallel export, priority (VIP) exports, and continuation in case the migration is interrupted. This ensures smooth recovery and the business will have the service running in no time.