Created
May 23, 2015 14:34
-
-
Save rufflabs/908a24a73a651f01b934 to your computer and use it in GitHub Desktop.
Returns true or false depending on if you are an administrator
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
function Test-Administrator | |
{ | |
$user = [Security.Principal.WindowsIdentity]::GetCurrent(); | |
(New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Elevated relaunch:
Also, could add
#requires -RunAsAdministrator
at the top to prevent launching without admin.