Solved

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

Posted on 2014-02-11
6
27,198 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
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
2
 
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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

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!

Question has a verified solution.

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

While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
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 …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

777 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