# Get-LocalGroups.ps1
# Gets local groups using WMI and Win32_Group class
# Effectively, the 6th sample from http://msdn.microsoft.com/en-us/library/aa394586
# Thomas Lee - tfl@psp.co.uk
# Get Win32 Group Accounts
$Accts=Get-WMIObjectWin32_Group|where {$_.LocalAccount}
# Display them
$accts |ftName, Sid, SidType, Status-autosize
This script produces the following output:
PS C:\foo> .\get-localgroups.ps1
Name Sid SidType Status
---- --- ------- ------
Administrators S-1-5-32-544 4 OK
Backup Operators S-1-5-32-551 4 OK
Certificate Service DCOM Access S-1-5-32-574 4 OK
Cryptographic Operators S-1-5-32-569 4 OK
Distributed COM Users S-1-5-32-562 4 OK
Event Log Readers S-1-5-32-573 4 OK
Guests S-1-5-32-546 4 OK
IIS_IUSRS S-1-5-32-568 4 OK
Network Configuration Operators S-1-5-32-556 4 OK
Performance Log Users S-1-5-32-559 4 OK
Performance Monitor Users S-1-5-32-558 4 OK
Power Users S-1-5-32-547 4 OK
Print Operators S-1-5-32-550 4 OK
Remote Desktop Users S-1-5-32-555 4 OK
Replicator S-1-5-32-552 4 OK
Users S-1-5-32-545 4 OK
SQLServer2005MSFTEUser$COOKHAM8$MICROSOFT##SSEE S-1-5-21-2376918343-887200126-108515810-1005 4 OK
SQLServer2005MSSQLServerADHelperUser$COOKHAM8 S-1-5-21-2376918343-887200126-108515810-1002 4 OK
SQLServer2005MSSQLUser$COOKHAM8$MICROSOFT##SSEE S-1-5-21-2376918343-887200126-108515810-1004 4 OK
SQLServer2005MSSQLUser$COOKHAM8$SQLEXPRESS S-1-5-21-2376918343-887200126-108515810-1003 4 OK
SQLServer2005SQLBrowserUser$COOKHAM8 S-1-5-21-2376918343-887200126-108515810-1001 4 OK
WSS_ADMIN_WPG S-1-5-21-2376918343-887200126-108515810-1006 4 OK
WSS_RESTRICTED_WPG S-1-5-21-2376918343-887200126-108515810-1007 4 OK
WSS_WPG S-1-5-21-2376918343-887200126-108515810-1008 4 OK
__vmware__ S-1-5-21-2376918343-887200126-108515810-1009 4 OK
#