Solved

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

Posted on 2014-02-11
6
25,541 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
help with PowerShell script for registry permissions 8 52
AD Account Lockout 22 39
Using cipher to decrypt files. 4 29
need help with active directory 4 27
In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
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 …

895 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

11 Experts available now in Live!

Get 1:1 Help Now