Try this:
Get-ADGroupMember -Identity "EMEASenders" -Recursive |
Get-ADUser -Property Mail |
Where-Object {$_.Enabled} |
Select-Object Mail |
Export-csv -path C:\temp\Email.csv -NoTypeInformation
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I'm using the below code to get a list of email addresses of users in an AD group. I need to exclude the disabled users from that. What do I need to add to achieve that?
Get-ADGroupMember -Identity "EMEASenders" -Recursive | Get-ADUser -Property Mail | Select-Object Mail | Export-csv -path C:\temp\Email.csv -NoTypeInformation
Try this:
Get-ADGroupMember -Identity "EMEASenders" -Recursive |
Get-ADUser -Property Mail |
Where-Object {$_.Enabled} |
Select-Object Mail |
Export-csv -path C:\temp\Email.csv -NoTypeInformation