Solved

Need help with Powershell Script for Exchange

Posted on 2010-08-24
12
248 Views
Last Modified: 2012-05-10
I need a power-shell script that can take an existing users mailbox, and copy the folder structure of the mailbox, while only copying the messages in the various folders that are older than a certain date.

Thanks
0
Comment
Question by:Methodman85
[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
  • 6
  • 5
12 Comments
 
LVL 28

Expert Comment

by:sunnyc7
ID: 33516032
what version of exchange ?
0
 
LVL 28

Assisted Solution

by:sunnyc7
sunnyc7 earned 100 total points
ID: 33516049
Export-Mailbox -Identity john@contoso.com -EndDate "03/01/2010 12:01:00" -PSTFolderPath C:\PST\john.pst

All mails before 3/1/2010 will be copied to c:\pst\john.pst

0
 
LVL 1

Author Comment

by:Methodman85
ID: 33516259
Is the only way to do this to a PST? I think that will work, I can just export the PST into the achieve mailbox.

You see the user does not want a PST file, she wants another "user" mailbox, because she wants everything stored on the server and nowhere else.

It's Exchange 2007
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 28

Expert Comment

by:sunnyc7
ID: 33516279
You can create another mailbox - called >USERarchive

Import the pst into that and load it as additional mailbox.

that's better than PST I think.
0
 
LVL 1

Author Comment

by:Methodman85
ID: 33516505
Indeed, that's what I'll do. Now another question. Since this is exporting to a PST file, it will just be creating a copy. It won't actually be moving the files. The reason I need to do this is because the users mailbox is approaching 9GB, so is there a way to turn this into an archive process, so that the files are actually moved?
0
 
LVL 2

Accepted Solution

by:
dm_mcelduff earned 400 total points
ID: 33518452
You actually do not need to export the mailbox to a PST file, you can just use the export-mailbox command to move direct to another mailbox.

offical guide: http://technet.microsoft.com/en-us/library/aa998579(EXCHG.80).aspx

an example of this would be to run the powershell command below:

export-Mailbox -Identity MailboxName -TargetMailbox ArchiveMailbox -EndDate <DateTime>

Then once you confirm the export is successful re-run the command with the additional switches below to clean up
export-Mailbox -Identity MailboxName -TargetMailbox ArchiveMailbox -EndDate <DateTime> -AllowMerge -DeleteContent

Note I haven't tested this so use with caution!

Note: The EndDate parameter specifies the end date for filtering content that will be moved from the source mailbox. Only items in the mailbox whose date is prior to or the same as the end date will be moved. When you enter a specific date, use the short date format that is defined in the Regional Options settings that are configured on the local computer. For example, if your computer is configured to use the short date format mm/dd/yyyy, enter 03/01/2006 to specify March 1, 2006.
0
 
LVL 1

Author Comment

by:Methodman85
ID: 33526431
It's asking me for TargetFolder parameter.
I want to keep the existing structure of the original mailbox. How can I do that?

[PS] C:\Documents and Settings\>export-Mailbox -Identity itsectest -TargetMailbox ARCTest -EndDate 8/22/2010

cmdlet Export-Mailbox at command pipeline position 1
Supply values for the following parameters:
TargetFolder:
0
 
LVL 1

Author Comment

by:Methodman85
ID: 33526449
If I say inbox it says.

StatusMessage                    : The target folder 'Inbox' is a special folder of target mailbox 'ARCTest', and is not supported by this command.
0
 
LVL 28

Expert Comment

by:sunnyc7
ID: 33526454
try mine
http:#33516049
0
 
LVL 1

Author Comment

by:Methodman85
ID: 33526774
I will, I will use that to do a full backup before I try the archive and delete options. I'm prepping an XP x86 VM to do this.
I should have this fully tested by tomorrow.
Thanks.
0
 
LVL 1

Author Closing Comment

by:Methodman85
ID: 33537380
Thanks!
I gave dm_mcelduff the main answer because this method saves me from having to manually go back to original mailbox and delete to old items.
0
 
LVL 28

Expert Comment

by:sunnyc7
ID: 33537409
Thanks for the points.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
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…
how to add IIS SMTP to handle application/Scanner relays into office 365.

695 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