Reconnecting to a loopback PSSession from another computer

On the server , open powershell and type

New-PSSession -ComputerName localhost

A new PSSession is created in the local computer, Get-PSSession returns the session information correctly.

Now go to another computer (client), and open Powershell and type

Get-PSSession -ComputerName  -UseSSL -Port 5986 -Credential (Get-Credential) -SessionOption (New-PSSessionOption -SkipRevocationCheck)

Nothing is returned (returns $null)

I’m 100% positive WinRM is set up properly and the firewall is not blocking access. To verify this:

On the client computer, type

New-PSSession -ComputerName  -UseSSL -Port 5986 -Credential (Get-Credential) -SessionOption (New-PSSessionOption -SkipRevocationCheck)

and I can see that the session is created successfully on the server.

And now go to another client computer (client2), and type

Get-PSSession -ComputerName  -UseSSL -Port 5986 -Credential (Get-Credential) -SessionOption (New-PSSessionOption -SkipRevocationCheck)

and I see that the session info is returned correctly.

To summarize:

  • A PSSession launched into the server, from the server (loopback) is
    not visible to client computers, only visible to the server.
  • A PSSession launched into the server, from the client is not visible to
    the server, but it is visible to all client computers.

Why?

did you try to Get-PSSession -Computername server on server itself ?
may be localhost not equal “server” in term of session binding ?

I try to create new-session -comp server on client and get-pssession on server => nothing
but when I try get-psssession -comp server on the server, then I see It