• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 655
  • Last Modified:

PowerShell to List Local Group Membership

Is there a way with powershell in Windows Server 2008R2 to list all members of  a specific group? They are all local users within a local group. I can use net localgroup "GroupName" to get the usernames but that doesn't show me FullNames and Descriptions which I need to view as well.

Thanks!
0
Winsoup
Asked:
Winsoup
  • 2
1 Solution
 
WinsoupAuthor Commented:
That gets all local user accounts. I only want to get local user accounts within a certain group. I would also only like to display the Name, FullName, and Description if that's possible.
0
 
QlemoC++ DeveloperCommented:
$localgroup = 'Administrators'
gwmi -query "select PartComponent, __Server from Win32_GroupUser where GroupComponent=`"Win32_Group.Domain='$env:Computername',Name='$localgroup'`"" |
  % { [WMI] $_.PartComponent } |
  ft -a Domain, Name, FullName, Description

Open in new window

0
 
WinsoupAuthor Commented:
Awesome, works perfect! Thank you!
0

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now