Created
July 17, 2018 17:28
-
-
Save h3nryza/576371e75dbc9dfcaeda800ed9134d2b to your computer and use it in GitHub Desktop.
Powershell AutoElevate a script
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
| #Elevate to Admin | |
| if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit } | |
| #Your code here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment