• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 398
  • Last Modified:

Use PowerShell to extract and user/dl with specific domain

Hello All,
I'm trying to find a way to extract users and groups with a specific email address (ie, @abc.com) and save it as an excel file.

someone asked me for all users and DL's ending in a sepecific domain email address. We receive email from a few domains and in AD i dont see an easy way to do that.

i was hoping EMS would be able to do this.
0
msidnam
Asked:
msidnam
  • 4
1 Solution
 
Ben HartCommented:
wait hold on.. thats not right..
0
 
Ben HartCommented:
get-recipient -ResultSize unlimited | where {$_.emailaddresses -match “test.local“} | select name,emailaddresses > c:\out.txt
0
 
Ben HartCommented:
Or maybe better..

Get-Mailbox -resultsize unlimited | Select-Object displayname -expandproperty emailaddresses| Where-Object {$_.smtpaddress -like "*domain.com*"}| Select-Object displayName,SmtpAddress | Export-csv C:\domain.csv
0
 
SubsunCommented:
You need to filter the groups and User mailboxes from Get-recipient command output.. For example..
Get-recipient -ResultSize unlimited | ?{($_.RecipientType -match "Group" -or $_.RecipientType -eq "UserMailbox") -and $_.emailaddresses -match "Test.com"} | Export-Csv C:\report.csv -NTI

Open in new window

0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now