$^ is a variable that expands to the last executed Powershell command.

You can run a command as another user using runas, so the following works:

runas /user:domain\administrator $^

To shorten that up a bit, you can do some magic with aliases. Take a look at this Technet article for more info.

EDIT: One caveat - $^ only executes the first command in a pipeline or multi-command line. If you need to redo an entire command that is peppered with pipes or semicolons, use Invoke-History instead (which defaults to the last full command in its entirety).


I have always though of JEA (Just Enough Administration) as an attempt to approximate some of the functionality of sudo. You can read about it here:

https://docs.microsoft.com/en-us/powershell/scripting/learn/remoting/jea/overview

Where is differs is that it uses PS remoting rather than applying to the local machine. This may be quite a critical difference, enough to push it too far away from sudo.

Elevating to account for User Account Control, using runas or something else, doesn't really fit well for me. It's more like a parallel of su -.