Link to home
Start Free TrialLog in
Avatar of Sid_F
Sid_F

asked on

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
Avatar of Rajitha Chimmani
Rajitha Chimmani
Flag of United States of America image

What do you mean by specific domain? Are you looking for specific domain in primary smtp address?
Avatar of Sid_F
Sid_F

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Rajitha Chimmani
Rajitha Chimmani
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
Avatar of Sid_F

ASKER

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
Avatar of Sid_F

ASKER

Sorry my fault had space in
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

Avatar of Sid_F

ASKER

Worked perfect thanks