Link to home
Start Free TrialLog in
Avatar of Angeal
Angeal

asked on

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

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.
ASKER CERTIFIED SOLUTION
Avatar of Mike Kline
Mike Kline
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

Avatar of Angeal
Angeal

ASKER

Exactly what I was looking for. Thanks Mike!
Glad to help out!
Nice script!  What would I need to add in order to include whether the members of the group have a smtp address?
And to add to that,  what if I wanted to see all the members of nested groups beneath a particular group?