Powershell command to export specific domain from exchange 2007

The command I use is below and works perfect to export user list. I want to use the below command but only want to export a specific domain. What do I need to add to the below command

Get-Mailbox -ResultSize unlimited |
where{$_.HiddenFromAddressListsEnabled -eq $false} | Select DisplayName, SAMAcco
untname, primarysmtpaddress |export-csv c:\userlist.csv
LVL 6
Sid_FAsked:
Who is Participating?
 
Rajitha ChimmaniCommented:
Try this

Get-Mailbox -ResultSize unlimited |
where{$_.HiddenFromAddressListsEnabled -eq $false -and $_.primarysmtpaddress -like "*domainA.com"} | Select DisplayName, SAMAcco
untname, primarysmtpaddress |export-csv c:\userlist.csv
0
 
Rajitha ChimmaniCommented:
What do you mean by specific domain? Are you looking for specific domain in primary smtp address?
0
 
Sid_FAuthor Commented:
I have multiple domains hosted on my exchange server. Users are either user@domainA.com or user@domainb.com I only want users from domainA.com
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Sid_FAuthor Commented:
Error message
Select-Object : A positional parameter cannot be found that accepts argument 'S
ystem.Object[]'.
At line:2 char:109
+  where{$_.HiddenFromAddressListsEnabled -eq $false -and $_.primarysmtpaddress
 -like "*domainA.com"} | Select <<<<  DisplayName, SAMAcco untname, primarysmtp
address |export-csv c:\userlist.csv
    + CategoryInfo          : InvalidArgument: (:) [Select-Object], ParameterB
   indingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell
   .Commands.SelectObjectCommand
0
 
Sid_FAuthor Commented:
Sorry my fault had space in
0
 
Rajitha ChimmaniCommented:
Get-Mailbox -ResultSize unlimited |where{($_.HiddenFromAddressListsEnabled -eq $false) -and ($_.primarysmtpaddress -like "*domainA.com")} | Select DisplayName, SAMAccountname, primarysmtpaddress |export-csv c:\userlist.csv

Open in new window

0
 
Sid_FAuthor Commented:
Worked perfect thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.