Last active
January 30, 2016 00:18
-
-
Save yangyer/f857776b40f317fd72ac to your computer and use it in GitHub Desktop.
Powershell sudo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Start-ElevatedUACSession { | |
$outputFiles = @{ | |
Standard = [System.IO.Path]::GetTempFileName(); | |
Error = [System.IO.Path]::GetTempFileName(); | |
} | |
$cmd = [string]::Join(" ", $args) | |
Write-Host "Executing Elevated: $cmd" | |
Start-Process powershell -Verb "runAs" -WindowStyle Hidden -Wait -ArgumentList "/Command ""& { $cmd > '$($outputFiles.Standard)' }""" | |
Get-Content $outputFiles.Standard | |
$outputFiles.Values | Remove-Item | |
} | |
Set-Alias sudo Start-ElevatedUACSession |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment