Working with local users and groups can get a little messy in PowerShell. But I wanted to share a quick one-liner you could use to list all the members of the Administrators group.
ManageEngine ADManager Plus - Download Free Trial
Exclusive offer on ADManager Plus for US and UK regions. Claim now!
This one-liner uses the ADSI type adapter. All you need to do is put in a computer name. My version uses the local computer by referencing $env:computername.
[cc lang="PowerShell"]
([ADSI]"WinNT://$env:computername/Administrators").invoke("Members") | foreach {$_.getType().InvokeMember("ADSPath","GetProperty",$null,$_,$null)}
[/cc]
The output will be the ADSI path of all members. This will work remotely as well using your current credentials which, of course, will need admin rights to the remote machine. I cover much more with local users and groups in Managing Active Directory with Windows PowerShell: TFM 2nd Ed from SAPIEN Press which should be out in a few weeks.
Here’s my take on it using a little function:
http://www.peetersonline.nl/index.php/powershell/helpful-function-of-the-day-get-localadmins/