Solved

PowerShell to List Local Group Membership

Posted on 2014-12-15
4
306 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 41

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 68

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
"Migrate" an SMTP relay receive connector to a new server using info from an old server.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now