Solved

Modify an Exchange PowerShell Script

Posted on 2011-03-09
17
716 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
[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
  • 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
Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 

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
 
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

Problems using Powershell and Active Directory?

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

Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
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…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

734 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