Solved

Need help with Powershell Script for Exchange

Posted on 2010-08-24
12
241 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
  • 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
 
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

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

Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
To show how to create a transport rule 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 Mail Flow >> Rules tab.:  To cr…
To show how to generate a certificate request 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 Servers >> Certificates…

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

14 Experts available now in Live!

Get 1:1 Help Now