Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Exchange 2007 PrimarySMTP CSV List

Posted on 2011-10-14
6
Medium Priority
?
226 Views
Last Modified: 2012-05-12
I need help in creating a very simple powershell script in Exchange 2007.  We implemented Google GMC and this requires a simple CSV file listing all primary email addresses.

I need to daily export a list of primary email addresses for all active users in specific org units.  The list should simply look as follow:

user1@domain.com
user2@domain.com
user3@domain.com
...

Any expert out there than can help me with this?

Thanks in advance!
0
Comment
Question by:SFCG
  • 4
6 Comments
 
LVL 10

Expert Comment

by:Thorrsson
ID: 36971736
Just the email addresses?
get-mailbox | select PrimarySMTPAddress

Open in new window

0
 

Author Comment

by:SFCG
ID: 36974521
No, I need this to be exported to a CSV file, but formated without the first line nor the quotes on each email address and from specific OUs in my Active Directory.

I have this, but I don't know how to change the formatting nor to select only specific OUs:
Get-Mailbox | select PrimarySmtpAddress | Export-CSV C:\temp\allmailboxes.csv

Any other ideas?  Thanks.
0
 

Accepted Solution

by:
SFCG earned 0 total points
ID: 36981524
I ended up running it as a DSQuery as follow at it worked perfectly for Google Message Continuity.  Thanks!
dsquery * OU=Users,DC=domain,DC=com -limit 0 -filter "(&(objectCategory=person)(objectClass=user)(mail=*))" -attr mail >"c:\temp\PrimaryEmailAddresses1.csv"
more +1 "c:\temp\PrimaryEmailAddresses1.csv" > "c:\temp\PrimaryEmailAddresses.csv"
del "c:\temp\PrimaryEmailAddresses1.csv"

Open in new window

0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

 

Author Closing Comment

by:SFCG
ID: 37010565
After spending a few hours trying different things this accomplished for I was looking for.
0
 
LVL 9

Expert Comment

by:chrismerritt
ID: 36982538
Just throwing it out there but this should also do the trick:

Get-Mailbox -OrganizationalUnit "OU=Users,DC=domain,DC=com" | Select PrimarySMTPAddress | Export-CSV "C:\Some Folder\file.csv" -NoType
0
 

Author Comment

by:SFCG
ID: 36982706
Chris, that also works, but I would still need to delete the first line.  Thanks!
0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  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

Among the most obnoxious of Exchange errors is error 1216 – Attached Database Mismatch error of the Jet Database Engine. When faced with this error, users may have to suffer from mailbox inaccessibility and in worst situations, permanent data loss.
Exchange database can often fail to mount thereby halting the work of all users connected to it. Finding out why database isn’t mounting is crucial and getting the server back online. Stellar Phoenix Mailbox Exchange Recovery is a champion product t…
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…
Screencast - Getting to Know the Pipeline
Suggested Courses

580 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