CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: PowerShell

Find all user accounts in the Administrator group

273 Views
Copy Code Show/Hide Line Numbers
foreach ($adminGroup in gwmi -computer "." Win32_Group | where {$_.SID -eq "S-1-5-32-544"} | select -Property __PATH) {foreach ($userPart in gwmi Win32_GroupUser | where {$_.GroupComponent -eq $adminGroup.__PATH} | select PartComponent) {gwmi Win32_Account | where {$_.__PATH -eq $userPart.PartComponent} | select @{Name="Account";Expression={$_.Caption}}}}
by kopelli
  November 11, 2009 @ 10:39pm
Tags:
Description:
This will list all the user accounts that are in the administrator group on the local machine.

Add a comment


Report Abuse
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate