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{$_.HiddenFromAddress ListsEnabl ed -eq $false} | Select DisplayName, SAMAcco
untname, primarysmtpaddress |export-csv c:\userlist.csv
Get-Mailbox -ResultSize unlimited |
where{$_.HiddenFromAddress
untname, primarysmtpaddress |export-csv c:\userlist.csv
What do you mean by specific domain? Are you looking for specific domain in primary smtp address?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Error message
Select-Object : A positional parameter cannot be found that accepts argument 'S
ystem.Object[]'.
At line:2 char:109
+ where{$_.HiddenFromAddress ListsEnabl ed -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 : PositionalParameterNotFoun d,Microsof t.PowerShe ll
.Commands.SelectObjectComm and
Select-Object : A positional parameter cannot be found that accepts argument 'S
ystem.Object[]'.
At line:2 char:109
+ where{$_.HiddenFromAddress
-like "*domainA.com"} | Select <<<< DisplayName, SAMAcco untname, primarysmtp
address |export-csv c:\userlist.csv
+ CategoryInfo : InvalidArgument: (:) [Select-Object], ParameterB
indingException
+ FullyQualifiedErrorId : PositionalParameterNotFoun
.Commands.SelectObjectComm
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
ASKER
Worked perfect thanks