PowerShell PSExec Shortcut

This is just a little .ps1 file that inserts some commands into a PSExec command. The file does require you to have PSExec installed somewhere on your enviroment path, but is a real time saver when you get used to it. Combined with other tools, you can do most things in three words or less (when the credentials are static). Just remember to surround the command with quotes ("") if it has triggers on it.

Example Useage:

pse someserver cmd - Puts you at a CMD shell on a someserver from within WPS. Use 'exit' to return back to local WPS console.
pse someserver "ipconfig /all" - Brings up IPConfig information for someserver right within PowerShell

These examples presume you have set your credentials within the .ps1 file.


#psexec command shortcut (no copy)

$target = $args[0]
$command = $args[1]
$password = $args[2]
$user = $args[3]

psexec \\$target -u $user -p $password CMD /c "$command"

For the purposes of posting it online, i have removed my static username nad password and replaced them with variables. You could go in and set the username and password in the script staticly to save yourself a lot of typing. That would be done by changing $args[2] to your password and $args[3] to your username. Make sure you surround both in quotes.