Skip to content

Instantly share code, notes, and snippets.

View sweeneyrobb's full-sized avatar

Robert Sweeney sweeneyrobb

View GitHub Profile
@sweeneyrobb
sweeneyrobb / Start-ExecuteUAC.ps1
Last active February 1, 2016 19:43 — forked from yangyer/Start-ExecuteUAC.ps1
Powershell sudo
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