Skip to content

Instantly share code, notes, and snippets.

@jpoehls
Created December 14, 2011 20:34
Show Gist options
  • Save jpoehls/1478380 to your computer and use it in GitHub Desktop.
Save jpoehls/1478380 to your computer and use it in GitHub Desktop.
Elevate-Process (sudo) for PowerShell
# Put this in your PowerShell profile.
function Elevate-Process
{
<#
.SYNOPSIS
Runs a process as administrator. Stolen from http://weestro.blogspot.com/2009/08/sudo-for-powershell.html.
#>
$file, [string]$arguments = $args
$psi = New-Object System.Diagnostics.ProcessStartInfo $file
$psi.Arguments = $arguments
$psi.Verb = "runas"
$psi.WorkingDirectory = Get-Location
[System.Diagnostics.Process]::Start($psi) | Out-Null
}
Set-Alias sudo Elevate-Process
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment