Solved

Powershell: List AD group members but filter users who are disabled

Posted on 2014-02-11
6
32,630 Views
Last Modified: 2016-03-30
Hi Experts,

I use the following line in Powershell to list AD Group members:

Get-ADGroupMember -identity "Group" | select name,samaccountname

How can I filter out the accounts that are disabled?

Thanks,

A.
0
Comment
Question by:Angeal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 57

Accepted Solution

by:
Mike Kline earned 500 total points
ID: 39851050
Give this a try

Get-ADGroupMember -identity "Group" | get-aduser | Where {$_.Enabled -eq $true} | format-table name, samaccountname -autosize

Thanks

Mike
3
 
LVL 14

Expert Comment

by:comfortjeanius
ID: 39851093
You can try this

Get-ADGroupMember -Identity "GroupName" -Recursive | %{Get-ADUser -Identity $_.distinguishedName -Properties Enabled }

Open in new window


To export it to a file

Get-ADGroupMember -Identity "GroupDN" -Recursive | %{Get-ADUser -Identity $_.distinguishedName -Properties Enabled } | Export-Csv C:\ADResuts.csv

Open in new window

1
 

Author Closing Comment

by:Angeal
ID: 39851110
Exactly what I was looking for. Thanks Mike!
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 57

Expert Comment

by:Mike Kline
ID: 39851116
Glad to help out!
0
 

Expert Comment

by:dlo32
ID: 41529443
Nice script!  What would I need to add in order to include whether the members of the group have a smtp address?
0
 

Expert Comment

by:dlo32
ID: 41529444
And to add to that,  what if I wanted to see all the members of nested groups beneath a particular group?
0

Featured Post

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

726 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