Solved

Powershell command to export specific domain from exchange 2007

Posted on 2014-11-13
7
139 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
Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

 
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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
This article explains how to install and use the NTBackup utility that comes with Windows Server.
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…
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…

756 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