Created
August 29, 2013 16:00
-
-
Save randomvariable/6380009 to your computer and use it in GitHub Desktop.
Check if a user is a member of a group
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
# Create a Windows Identity Principal (note the cast) | |
$principal = [Security.Principal.WindowsPrincipal](new-object System.Security.Principal.WindowsIdentity("<username>@<domain>")) | |
# Check if it is a member of a group | |
$princial.IsInRole("<domain>\<group name>") | |
# Other useful things you can do: | |
$identity = (new-object System.Security.Principal.WindowsIdentity("<username>@<domain>")) | |
# Token size | |
$identity.Token | |
# Groups | |
$identity.Groups |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment