Solved

PowerShell to List Local Group Membership

Posted on 2014-12-15
4
367 Views
Last Modified: 2014-12-19
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
Comment
Question by:Winsoup
  • 2
4 Comments
 
LVL 42

Expert Comment

by:Amit
ID: 40501036
0
 
LVL 3

Author Comment

by:Winsoup
ID: 40501154
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
 
LVL 69

Accepted Solution

by:
Qlemo earned 500 total points
ID: 40509461
$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
 
LVL 3

Author Closing Comment

by:Winsoup
ID: 40509499
Awesome, works perfect! Thank you!
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question