List of local admin groups on Windows 2008 Server

by Redman20111 at 2012-11-04 08:14:37

Hi

I have a couple of servers running Windows 2008 Server, they are running various applications for our company.

Within each server there is the Administrator group and also some specific (local) groups for our company:

ITAdmins
Helpdesk Admins
Vendors

Every week, I would like to run a script that will pull the membership of the local groups on the server. I have an admin server running Powershell 2 and I was thinking of using this.

Please note, the groups I mentioned above aren’t Domain Security/Distribution Groups within Active Directory, they are local groups on the servers themselves.

Thanks in advance for any assistance.
by Lembasts at 2012-11-04 12:57:15
I googled "powershell list local groups" and this came up:
$strComputer = "XYZ"

$computer = [ADSI]("WinNT://" + $strComputer + ",computer")
$computer.name

$group = $computer.psbase.children |where{$_.psbase.schemaclassname -eq "group"}

foreach ($member in $group.psbase.syncroot)
{$member.name}

It was on myitforum so Im not going to take the credit…

However, I have never seen this psbase thing before. Does anyone know where the properties and methods of this psbase stuff is documented?
by Klaas at 2012-11-05 00:16:05
The objects Powershell shows you are often not the original objects, but ‘adapted’ versions, usually with less members.
When you do need some property which is not included with the PS object but it is in the original, you can retrieve that by using the psbase version of the object.
by RichardSiddaway at 2012-11-05 10:17:27
The psbase construct shows the base object before PowerShell does any additions or subtractions. It was necessary to do this in a lot of cases in PowerShell v1 but its not needed as much with the later versions
by kittH at 2012-11-07 06:46:15
There’s a WMI function to do that as well:
http://gallery.technet.microsoft.com/sc … ns#content