Created
October 9, 2020 09:32
-
-
Save eizedev/b6c2545505389b0b3cac79d8e37e07b1 to your computer and use it in GitHub Desktop.
One-Liner to run the current script elevated as administrator if not already run as admin. Just copy&paste this oneliner to the top of your scripts.
This file contains 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 (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs -Wait } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment