none
Enter-PSSession : Connecting to remote server failed with the following error message

    Question

  • Hello All,

    I am trying to connect to my exchange server via PowerShell. When I ran the following PS command:

    Enter-PSSession -ComputerName Exch01  -Credential SAMO\Admin  -Authentication Default

    I got the following error:

    Enter-PSSession : Connecting to remote server failed with the following error message : The client cannot connect to the destination specified in the re
    quest. Verify that the service on the destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service
     running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyz

    WinRM service is started on Exchange server. Any thoughts?

    Friday, November 18, 2011 6:48 PM

All replies

  • you have to configure trusted hosts and listeners

    http://msdn.microsoft.com/en-us/library/windows/desktop/aa384372%28v=vs.85%29.aspx

    http://www.computerperformance.co.uk/powershell/powershell_wsman.htm

    Friday, November 18, 2011 7:01 PM
  • and also check firewall for ports 5985http 5986https
    http://blog.powershell.no/2010/03/04/enable-and-configure-windows-powershell-remoting-using-group-policy/
    Friday, November 18, 2011 7:04 PM
  • On the Exchange server, have you enabled remoting?  Open an elevated Powershell prompt and run:

    Enable-Psremoting

    ...and follow the prompts.

     


    [string](0..9|%{[char][int](32+("39826578840055658268").substring(($_*2),2))})-replace "\s{1}\b"
    • Edited by Bigteddy Saturday, November 19, 2011 6:07 AM
    Saturday, November 19, 2011 6:06 AM
  • IMPORTANT- If this is Exchange 2010, I would be very, very careful with making any WinRM/remoting changes.  Please advise...

    If Exchange 2007, then you are pretty safe in making some changes to get this working.

    Saturday, November 19, 2011 5:12 PM
    Moderator
  • Hello All,

    Sorry for the late reply. We are using Exchange 2010. I have checked the firewall ports are they are open, we even disabled firewall, but we still have the issue.

    I will read the http://www.computerperformance.co.uk/powershell/powershell_wsman.htm provided by KloinerFeigling83

    Wednesday, November 23, 2011 12:29 PM
  • What happens when you run this on the Exchange server?

    http://gallery.technet.microsoft.com/Exchange-Management-b9d918b1

    Karl


    My Blog: http://unlockpowershell.wordpress.com
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ("6B61726C6D69747363686B65406D742E6E6574"-split"(?<=\G.{2})",19|%{[char][int]"0x$_"})
    Wednesday, November 23, 2011 3:22 PM
  • Hi Yassar,

    Recently Microsoft changed default port of WinRM to 5985 & 5986, please check the following Blog

    https://blogs.technet.microsoft.com/christwe/2012/06/20/what-port-does-powershell-remoting-use/

    Also you can check remote power shell is enables on server end

    use Enable-PSRemoting -Force to allow remote power shell

    Thanks,
    NTRao.


    • Edited by NTRao Thursday, June 8, 2017 3:23 PM
    • Proposed as answer by NTRao Thursday, June 8, 2017 3:23 PM
    Thursday, November 24, 2016 11:34 AM
  • good documentation. Cheers
    Tuesday, March 14, 2017 2:29 PM
  • Thanks Andy & Please mark as answer if it helps!
    Monday, June 12, 2017 3:22 PM