Created
May 1, 2019 19:40
-
-
Save ismits/ad1a5f76975448a945c0893655882486 to your computer and use it in GitHub Desktop.
PowerShell function to test whether the current script is running as an elevated admin
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
function Is-Elevated | |
{ | |
$wid = [System.Security.Principal.WindowsIdentity]::GetCurrent() | |
$prp = New-Object System.Security.Principal.WindowsPrincipal($wid) | |
$adm = [System.Security.Principal.WindowsBuiltInRole]::Administrator | |
$IsAdmin = $prp.IsInRole($adm) | |
return $IsAdmin | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment