PoshCode Logo PowerShell Code Repository

elevate-process (sudo) (modification of post by Peter Provost view diff)
diff | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/696"></script>download | new post

As a former UNIX guy, I love the non-admin stuff in Vista, but got annoyed keeping two shells open (one admin and one non-admin). I wanted sudo! PowerShell made that easy. Just put this in your $profile script. Enjoy!

  1. function elevate-process
  2. {
  3.         $file, [string]$arguments = $args;
  4.         $psi = new-object System.Diagnostics.ProcessStartInfo $file;
  5.         $psi.Arguments = $arguments;
  6.         $psi.Verb = "runas";
  7.         $psi.WorkingDirectory = get-location;
  8.         [System.Diagnostics.Process]::Start($psi);
  9. }
  10.  
  11. set-alias sudo elevate-process;

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me