Interactive remoting in CTP3

Rate This
  • Comments 18

Today let's talk about one of the cool new features of Windows PowerShell V2 - Interactive Remoting.

Let’s start with an example:

PS> $env:COMPUTERNAME # Check local computer name.                                                                      
PS> Enter-PSSession Vladimia06 # Remote to other computer.
[vladimia06]: PS C:\Users\Vladimia\Documents> $env:COMPUTERNAME # Check remote computer name.
[vladimia06]: PS C:\Users\Vladimia\Documents> $PSVersionTable # Check powershell version on remote computer.

Name Value
---- -----
CLRVersion 2.0.50727.3521
BuildVersion 6.1.7015.0
PSVersion 2.0
PSCompatibleVersions {1.0, 2.0}

[vladimia06]: PS C:\Users\Vladimia\Documents> function prompt {} # See how prompt function is always prefixed by [<compu
tername>]: in interactive remoting.
[vladimia06]: PS>Exit-PSSession # Exit remote session.

As you can see Enter-PSSession starts interactive remoting session and Exit-PSSession takes you out of it. The aliases for these commands are etsn and exsn. You can also use exit keyword instead of Exit-PSSession.

Interactive remoting uses the same remoting infrastructure as other PowerShell remoting cmdlets. WinRM provides the transport and maintains a listener service, which is responsible for creation of the remote PowerShell sessions.

Similar to Invoke-Command, you can use computer name to establish remote connection. In that case remote PSSession is created implicitly for you when you enter and disposed of after you exit.

Alternatively, you can create a persistent session using New-PSSession command and use it with Enter-PSSession. In that case the session won’t be closed after you finish and you can enter it multiple times exactly when you need it.

PS> $s = nsn vladimia06  # Create a persistent remote session.                                                          
PS> etsn $s
[vladimia06]: PS C:\Users\Vladimia\Documents> $x = 123 # Create a variable.
[vladimia06]: PS C:\Users\Vladimia\Documents> exsn
PS> etsn $s
[vladimia06]: PS C:\Users\Vladimia\Documents> $x # Check that a variable is still there
[vladimia06]: PS C:\Users\Vladimia\Documents> exsn
PS> icm $s {$x} # The variable created in interactive remoting can also be accessed using remote invocation.
PS> rsn $s # Close the remote session.

Note that the variables that are created in remote session won’t be available in your local runspace when you exit. You need to use Invoke-Command to get them to the client side. The corresponding object will be serialized over the wire and reassembled on the other side. Primitive types will be restored as fully functional ‘live’ objects, but more complex object will be reduced to deserialized ‘property bags’. We will talk more on serialization in one of the next posts.

Try it, use it, love it!
Vladimir Averkin
Windows PowerShell Team

Leave a Comment
  • Please add 2 and 4 and type the answer here:
  • Post
  • Will remoting in Powershell work on Windows 2003 R2 with the CTP3 and the WS-Management v1.1?  I get errors, but I am new to this config.  Any help is appreciated.

  • How do I get past this?

    Enter-PSSession : Connecting to remote server failed with the following error message : The WinRM client cannot process

    the request. If the authentication scheme is different from Kerberos, or if the client computer is not joined to a dom

    ain, then HTTPS transport must be used or the destination machine must be added to the TrustedHosts configuration setti

    ng. Use winrm.cmd to configure TrustedHosts. You can get more information about that by running the following command:

    winrm help config.

  • @J-rod

    Sorry but remoting does not work with WS2003 R2 at this point.  That will come in a future CTP.  I know that that is a headache - I'm sorry.

    Experiment! Enjoy! Engage!

    Jeffrey Snover [MSFT]

    Windows Management Partner Architect

    Visit the Windows PowerShell Team blog at:

    Visit the Windows PowerShell ScriptCenter at:

  • @ Doug:

    Please provide more information about your connection scenario. Is your your target computer in the same domain, different domain, or workgroup or internet. Is remoting installed and enabled on the target computer? Is WinRM service running on the target computer? Are PowerShell and WinRM CTP3 installed on both computers?



  • I understand that you are committed to WinRM as opposed to something like SSH - but the fact that WinRM is not supported on Windows 2003 is very limiting right now.

    I would like to use the SSH server from nSoftware, but I have like 3 machines alone that are my personal workstations, not to mention a server in a VM that I would want it on so that gets pretty costly.

    So in your comment above you indicate that WinRM *will* be supported on Windows 2003 at RTM?

    In the interim, I wonder if there is some way to address the problems of running PowerShell under Windows's telnet server? In particular, scrolling doesn't work because the telnet server treats the scrolling buffer as overwrites when it sends the ANSI escape sequences?

  • Jeff,

    Thanks for the quick response.  What I'm trying to do is get information similar to what the ssldiag.exe tool pulls.  Do you know any of the developer's of that tool so perhaps they could answer a couple of questions for me?



  • @Vladimir

    I tried doint the Enter-PSSession on the same machine, perhaps that is the problem, is is VISTA Ultimate.

    I have the CTP3 for both PoSh and WinRM installed. WinRM is running.

    I am not sure how to check if remoting is installed and enabled.

    If it helps, I can successfully do a Start-PSJob {dir} and Receive-Job for the results.

    I installed Windows 7 on a VPC. I tried to do a remote command from it to the VISTA host. I got a similar error.

    Is there a readme, post or msdn write up for trouble shooting this?


  • @J-Rod

    Also, just to add, for doing remoting both ends must have the same PowerShell version and same WinRM version also.  Like Jeffrey mentions, today that means you can only remote with Vista SP1 and Server 2008 systems.

    I've not tried the Windows 7 beta to see if this can talk to the public downloads of PowerShell/WinRM currently available for Vista SP1 and Server 2008.


    I've also seen this, and never did take notes to figure out if it always occurs, or perhaps something is saved during an upgrade, thus I don't notice that I get this error again.

    Check this from PowerShell or DOS:

    winrm get winrm/config/client

    You may see:


    TrustedHosts =


    I can't connect to a WinRM 2.0 system right now to take a last peak at that setting.

  • Hi,

    I installed PS2 CTP3 as per instructions on 2 Vista SP1's (1 Enterprise, and 1 Ultimate). On one, Remoting or WinRM seems broken. I get the error below. Since PS2 is so new, googling for the above error message yielded nothing - so I hope someone can help? Thanks!

    PS C:\Windows\System32> new-pssession

    New-PSSession : [localhost] Connecting to remote server failed with the following error message : WS-Management cannot process th

    e request. The operation failed because of an HTTP error. The HTTP error (12152) is: The server returned an invalid or unrecogniz

    ed response .

    At line:1 char:14

    + new-pssession <<<<

       + CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransport


       + FullyQualifiedErrorId : RemoteRunspaceOpenFailed

  • @Doug

    To enable remoting on your machine you need to run

    Enable-PSRemoting -force

    The fact that you can run Start-Job on your box means you have already done it as jobs require remoting to be able to work.

    Now as the error message says, you need to add target computer to your WinRM Trusted hosts:

    set-item WSMan:\localhost\Client\TrustedHosts <computername> -force

    To enable remote connection for all computers you need to put * instead of <computername>

    Hope this helps. Please let me know if it worked for you.



  • @ YL Woo

    Please note that WinRM CTP3 should also be installed on both machines.

    Hope this helps,


  • Hi,

    I saw PowerShell remoting introduction with Linux OS last year, how would that realize?

  • @Vladimir

    Thank you, that worked. Also just fyi, a wsmprovhost.exe window popped up.


    Thanks, I am guessing your approach is equivalent commandline way of the wsman provider. I get this message.


       Message = The WS-Management service cannot process the request. The resource URI (

    wsman/1/connfig/client) was not found in the WS-Management catalog. The catalog contains the metadata that describes res

    ources, or logical endpoints.

    Error number:  -2144108485 0x8033803B

    The WS-Management service cannot process the request. The resource URI is missing or it has an incorrect format. Check t

    he documentation or use the following command for information on how to construct a resource URI: "winrm help uris".

  • On my Windows7 machine (installed in a VPC) I followed the instructions for the TrustedHosts do the Enter-PSSession and get this.

    Enter-PSSession : Connecting to remote server failed with the following error message : WS-Management could not connect

    to the specified destination: (windows7:80).

    At line:1 char:16

    + Enter-PSSession <<<<  windows7

       + CategoryInfo          : InvalidArgument: (windows7:String) [Enter-PSSession], PSRemotingTransportException

       + FullyQualifiedErrorId : CreateRemoteRunspaceFailed,Microsoft.PowerShell.Commands.EnterPSSessionCommand

  • @Vladimir,

    WinRM CTP3 are installed on both machines, and I haven't tried remoting to each other. I was just trying a localhost test. The remoting works on the Vista SP1 Enterprise, but not the Vista SP1 Ultimate. Strange. I even turned the firewall off.

    I seem to be getting Doug's latest error? Though his is slightly different.

Page 1 of 2 (18 items) 12

Interactive remoting in CTP3