Created
July 29, 2015 16:16
-
-
Save mbrownnycnyc/55720cc4d1c999c0c7d4 to your computer and use it in GitHub Desktop.
Very quick/raw script to get a list of members of local admin group in a resultant !! separated list
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
#--- Lists local users in local Administrators group: --- | |
((get-wmiobject Win32_GroupUser -computer $computername | ` | |
where { ` | |
( $_.GroupComponent -like '*Administrators*' ) ` | |
-and | |
( $_.GroupComponent -notlike '*$((get-wmiobject win32_computersystem).domain.split('.')[0])*' ) ` | |
-and ` | |
( $_.PartComponent -like '*Win32_UserAccount*') ` | |
-and ` | |
( | |
( $_.PartComponent -like "*Domain=""$computername""*") ` | |
-or ` | |
( $_.PartComponent -notlike "*Domain=""$((get-wmiobject win32_computersystem).domain.split('.')[0])""*") ` | |
) ` | |
} ` | |
).partcomponent) | foreach { ($_).split('"')[1,3] ; "!!"} | |
#--- Lists local and domain users in local Administrators group: --- | |
((get-wmiobject Win32_GroupUser -computer $computername | ` | |
where { ` | |
( $_.GroupComponent -like '*Administrators*' ) ` | |
-and | |
( $_.GroupComponent -notlike '*$((get-wmiobject win32_computersystem).domain.split('.')[0])*' ) ` | |
-and ` | |
( $_.PartComponent -like '*Win32_UserAccount*') ` | |
-and ` | |
( | |
( $_.PartComponent -like "*Domain=""$computername""*") ` | |
-or ` | |
( $_.PartComponent -like "*Domain=""$((get-wmiobject win32_computersystem).domain.split('.')[0])""*") ` | |
) ` | |
} ` | |
).partcomponent) | foreach { ($_).split('"')[1,3] ; "!!"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment