Remoting to Nano Server made easy

I find myself typing the following 3 lines over and over every day:

$ip = ""

$s = New-PSSession -ComputerName $ip -Credential ~\Administrator

Enter-PSSession $s

So, I decided to put an end to this, and not only save time typing, but save my wrists from carpel tunnel syndrome :)

Now, I type:

go ""

If I exit the remote session and need to re-enter, I type:


The functions:

function go($ipAddr)


    $global:ip = $ipAddr

    $global:s = New-PSSession -ComputerName $global:ip -Credential ~\Administrator

    Enter-PSSession $global:s


function enter


    Enter-PSSession $global:s



  • The variables have global scope, so that they would persist in your session, if you ever need to reuse them ($ip and $s), say for a copy operation or something.
  • Put these functions into your profile, so they get automatically loaded every session.
  • You’ll notice that these functions do not adhere to the PowerShell Verb-Noun naming standards. That’s because these are quick-and-dirty accelerator functions which really improve my productivity, and are not functions that I’ll be sharing with the world.

 When Andrew saw this function, he wanted me to extend it to keep track of more than one session, so that you can ultimately say: enter 3 (for the third session).  What do you guys think?