ENTER-PSSESSION Powershell Tool
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.
Something like this:
$(Computer:TARGETHOSTNAME) is a variable available in that menu to the right marked (x) in blue.
Awesome! Works like a charm! Thanks.
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.
Same here. It used to work as described but after one upgrade it change it behavior to what @TysonBryner mentioned.
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!)
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)
Please sign in to leave a comment.