Created
September 9, 2023 00:46
-
-
Save roelds/7e045952ea1736ed69fc92190d21bbbc to your computer and use it in GitHub Desktop.
Require or Verify PowerShell Script Run 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
#Requires RunAsAdministrator | |
# put above comment at top of script to prevent running of script if it was not run as admin | |
# or quietly check for script run as admin: | |
([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment