Solved

Modify an Exchange PowerShell Script

Posted on 2011-03-09
17
709 Views
Last Modified: 2012-05-11
Can the following Exchange PowerShell script be modified to run against a list of users and the output .pst file have the users name in it or something that associates to the user?

Export-Mailbox -Identity joe@va.gov –PSTFolderPath C:\Temp\joe.pst -DeleteContent
0
Comment
Question by:vhaperbaugub
  • 10
  • 7
17 Comments
 
LVL 74

Expert Comment

by:Glen Knight
ID: 35082037
You would use something like:

Get-Mailbox -Database “mailbox database” | Export-Mailbox -PSTFolderPath D:\PSTs -DeleteContent

This will automatically create a PST with the users Exchange Alias name.
0
 

Author Comment

by:vhaperbaugub
ID: 35082049
Will the script above run against a list of users?
0
 
LVL 74

Expert Comment

by:Glen Knight
ID: 35082051
As in a CSV list?
0
 

Author Comment

by:vhaperbaugub
ID: 35082086
CSV or txt list.
0
 
LVL 74

Expert Comment

by:Glen Knight
ID: 35082230
import-csv "d:\scripts\spamrecipients.csv" | ForEach-object -process {Export-Mailbox -PSTFolderPath D:\PSTs -DeleteContent}

I would suggest taking away the -deletecontent part until you know it's workign.
0
 

Author Comment

by:vhaperbaugub
ID: 35082445
Ok, I'll test it out and let you know.....Thanks
0
 

Author Comment

by:vhaperbaugub
ID: 35083463
When I run : import-csv "c:\mailboxsizes\test.csv" | ForEach-object -process {Export-Mailbox -PSTFolderPath C:\Temp}


Its asking for the identity, looks like its not importing the csv file.
0
 

Author Comment

by:vhaperbaugub
ID: 35084079
Looking again, its importing the CSV file, i'm getting this:

cmdlet Export-Mailbox at command pipeline position 1
Supply values for the following parameters:
Identity:
0
Don't lose your head updating email signatures!

Do your end users still have the wrong email signature? Do email signature updates bore you or fill you with a sense of dread? You can make this a whole lot easier on yourself by trusting an Exclaimer email signature management solution. Over 50 million users do...so should you!

 
LVL 74

Expert Comment

by:Glen Knight
ID: 35084155
So sorry, of course it is, we haven't told it what to read from the CSV file.

See the example here which combined with the one I gave you above should sort you out: http://www.minasi.com/forum/topic.asp?TOPIC_ID=23732
0
 

Author Comment

by:vhaperbaugub
ID: 35084318
I want it to read the DisplayName, how would I modify the script to read the DisplayName and then process it?
0
 
LVL 74

Expert Comment

by:Glen Knight
ID: 35084403
Try:

foreach ($user in (Import-CSV "C:\export-mailbox.csv")) { Export-Mailbox "$($user" -PSTFolderPath "C:\Temp" }

(I'm mobile at the moment so if that doesn't work I will check it out when I get back to my desk)
0
 

Author Comment

by:vhaperbaugub
ID: 35084957
It doesn't seem to run, I believe the "$($user" portion seems to be the culprit. I tried some mods but nothing seems to work.
0
 

Author Comment

by:vhaperbaugub
ID: 35086228
I got it to work.....I used "$($user.displayname)"

Do you know what switch to use to make the script run without prompting me for "yes" or "no" for each user?
0
 
LVL 74

Expert Comment

by:Glen Knight
ID: 35086259
Add: -Confirm:$false before the last }
0
 

Author Comment

by:vhaperbaugub
ID: 35086427
That worked.....here is what it looks like:

foreach ($user in (Import-CSV "C:\mailboxsizes\test.csv")) { Export-Mailbox "$($user.displayname)" -PSTFolderPath "C:\Temp" -Confirm:$false  }

When I'm ready, where do I place -DeleteContent in the script?
0
 
LVL 74

Accepted Solution

by:
Glen Knight earned 500 total points
ID: 35086434
Just before the -confirm:$false
0
 

Author Comment

by:vhaperbaugub
ID: 35086478
Ok, I think that about does it for this.....Thanks for your help!!!!.....you saved me hours of time with the mods to this script.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
In this video we show how to create a Shared Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Sha…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now