I’ve grown quite attached to using Windows Terminal to run PowerShell, cmd.exe, and various other command-line environments. As it implements a fairly standard console environment and can be customized, it’s pretty easy to add other things to it, e.g. Python.
But what about PSExec? Easy enough to try by editing the configuration by clicking the down arrow. If you don’t have a JSON editor installed, just choose Notepad.
Add entries like what I’ve highlighted below:
And the same, in text form:
"name": "PSExec -s cmd.exe",
"commandline": "c:\pstools\psexec.exe -s cmd.exe"
"name": "PSExec -s powershell.exe",
"commandline": "c:\pstools\psexec.exe -s powershell.exe"
I specified the full path to psexec.exe (I saved all the SysInternals tools to that path), substitute your appropriate path.
After saving those changes and going back into Terminal, you’ll see the two new options:
If you look carefully, you’ll see one other change from the previous screenshot to this one: Terminal is now running with admin rights. That’s because PSExec requires admin rights; it will fail with an “access denied” error if you don’t do that.
Choosing the first option displays a command prompt:
After closing that (since you can only have one PSExec session open to the local machine), you can then open a PowerShell session:
In this case, I’m using PSExec to establish a session to my own device (useful to test things in system context), but you could just as easily put a different host name in the profile’s command line. (It would be nice if Terminal would prompt for a name. If it can do that, let me know – got tired of reading through the docs…)
Categories: Windows 10