Created
March 13, 2019 17:16
-
-
Save victory-sokolov/577b62ac30c07888667ddf601c655ca8 to your computer and use it in GitHub Desktop.
Execute PowerShell script as admin
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
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