Important Notice: On February 29th, this community was put into read-only mode. All existing posts will remain but customers are unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

ENTER-PSSESSION Powershell Tool

Hello,

I am interested in having a tool in PDQ Inventory where I can right click on a computer object and be able to open a Power Shell session on the machine in question.  If you open PS and use the command ENTER-PSSESSION MACHINENAME you get a remote Power Shell window to enter commands in.  Is this something that you could add or could someone show me a way to do it?  Thanks.

0

Comments

6 comments
Date Votes
  • Something like this:

    $(Computer:TARGETHOSTNAME) is a variable available in that menu to the right marked (x) in blue.

     

    Yields this:

     

    0
  • Awesome!  Works like a charm! Thanks.

    0
  • Interesting.. I've created the same tool, but it doesn't seem to connect to the remote machine. It leaves me at an open powershell prompt on my local local machine in the admin arsenal temp folder.

    From there I can type the Enter-PSSession command and it works, but I can't get it to enter automatically.

    0
  • Same here. It used to work as described but after one upgrade it change it behavior to what @TysonBryner mentioned.

    0
  • For those that searched for this solution like me, I managed to get this working in Inventory 17 using quotes around the variable and ensuring 'leave shell open' was set. (You can obviously choose your own shortcut key!)

    remote powershell session

    0
  • Couple of things about doing this.

    1) You are leaving sessions to computers open. Just closing the powershell window does not actually remove the session. You need to exit then issue remove-pssession 

    2) The full script is easy. Because you should be closing your sessions, you should be required to have the new-pssession line every time you attempt to re-connect.

    $Session = New-PSSession -computername $(Computer:TARGETHOSTNAME)
    Enter-PSSession $Session

    0