How to fix connection failing in PowerShell

673 Views Asked by At

We are running our PowerShell Script in Remote Windows Server 2019. We use Connect-AzureAD and Connect-IPPSsesion. The script took about 3 hours to complete the whole process. It was working fine a few weeks ago but we're getting this error the past few day for some reason.

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.

It able to connected when the script start but we got that error during the process and stop the script.

I've been google the past few days and I found this documentation

https://learn.microsoft.com/en-us/exchange/troubleshoot/administration/fail-to-start-exchange-management-shell-console

I've tried the following

  • I've try to do the solutions that it provided in doc but there is no IIS and MSExchangePowerShellAppPool in our Remote Desktop.
  • I checked the User and it has the remotepowershell enabled (Always has been)
  • I checked WinRM QuickConfig and it set up properly
  • I change our proxy address to a different proxy address

but still no luck so any suggestion or help would be really appreciated.

1

There are 1 best solutions below

0
Imran On

By default, MSExchangePowerShellAppPool without running this application it is complex to find a solution. If you don't have MS Exchange PowerShell in your Desktop, please try the below.

Try using below cmdlet with Windows PowerShell

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://<ServerFQDN>/PowerShell/ -Authentication Kerberos -Credential $UserCredential
Import-PSSession $Session -DisableNameChecking

Reference: Connect to a remote Exchange server

Alternatively, you can use EMTshooter The local (target) Exchange server's EMTshooter programme runs there and looks for any issues that might affect the management tools attached to it.

  • Make sure ipv4 is used for communication and C:\Windows\system32\iis_ssi.dll exists.