The connection to the specified remote host was refused. Verify that the WS-Management service is running on the remote host and configured to listen for requests on the correct port and HTTP URL.

Sayantan Raha 6 Reputation points
2022-04-20T08:39:03.543+00:00

When we are trying to connect to virtual directory
$session = new-pssession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://oa.***Domain****.com/powershell" -AllowRedirection -SessionOption $sessionOption -Authentication Kerberos

getting the below error

new-pssession : [oa.domain.com] Connecting to remote server oa.domain.com failed with the following error
message : The connection to the specified remote host was refused. Verify that the WS-Management service is running on
the remote host and configured to listen for requests on the correct port and HTTP URL. For more information, see the
about_Remote_Troubleshooting Help topic.
At line:1 char:12

  • $session = new-pssession -ConfigurationName Microsoft.Exchange -Conne ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotin
    gTransportException
  • FullyQualifiedErrorId : CannotConnectWinRMService,PSSessionOpenFailed
Exchange | Exchange Server | Management
{count} vote

2 answers

Sort by: Most helpful
  1. Sayantan Raha 6 Reputation points
    2022-04-20T09:00:20.45+00:00

    HTTP is getting connected successfully, but getting error while connecting through HTTPS

    0 comments No comments

  2. Aholic Liang-MSFT 13,886 Reputation points Microsoft External Staff
    2022-04-21T07:15:21.337+00:00

    Hi @Sayantan Raha ,

    According to the official Microsoft documentation I have found a piece of information that may be of help to you . You may need to use http instead of https in the ConnectionUri value.
    ( https://learn.microsoft.com/en-us/powershell/exchange/connect-to-exchange-servers-using-remote-powershell?view=exchange-ps)
    195021-2022-04-21-145854.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.