Solved

Powershell command to export specific domain from exchange 2007

Posted on 2014-11-13
7
142 Views
Last Modified: 2014-11-13
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
0
Comment
Question by:Sid_F
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 16

Expert Comment

by:Rajitha Chimmani
ID: 40441355
What do you mean by specific domain? Are you looking for specific domain in primary smtp address?
0
 
LVL 6

Author Comment

by:Sid_F
ID: 40441386
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
 
LVL 16

Accepted Solution

by:
Rajitha Chimmani earned 500 total points
ID: 40441391
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Author Comment

by:Sid_F
ID: 40441406
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
 
LVL 6

Author Comment

by:Sid_F
ID: 40441411
Sorry my fault had space in
0
 
LVL 16

Expert Comment

by:Rajitha Chimmani
ID: 40441412
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
 
LVL 6

Author Comment

by:Sid_F
ID: 40441416
Worked perfect thanks
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
Read this checklist to learn more about the 15 things you should never include in an email signature.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question