Skip to content

Instantly share code, notes, and snippets.

@victory-sokolov
Created March 13, 2019 17:16
Show Gist options
  • Save victory-sokolov/577b62ac30c07888667ddf601c655ca8 to your computer and use it in GitHub Desktop.
Save victory-sokolov/577b62ac30c07888667ddf601c655ca8 to your computer and use it in GitHub Desktop.
Execute PowerShell script as admin
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment