PS Exchange Export Mailbox Inbox subfolders into separate PST


First Sorry for my English i don't practice so ...

I have a problem :

I want to export all the subfolders in the Inbox Folder to a separate pst

I have found a PS command to list the subfolders :

foreach-object { Get-MailboxFolderStatistics -Identity <MailboxID> -FolderScope Inbox | select-object Name }

Open in new window

This works perfect so i thinked that this going to work :

foreach-object {foreach-object { Get-MailboxFolderStatistics -Identity <MailboxID> -FolderScope Inbox | select-object Name } | New-MailboxExportRequest -Mailbox <MailboxID> -IncludeFolders "Inbox/$_" -FilePath \\Mypath\inbox-$_.pst }

Open in new window

But i see that we can't include pipe into pipe ...

That's where i'm stucked !

Can anyone help a PS/Exchange newbie ?
Yohann JARRIERTechAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Michael PfisterCommented:
Can't test here but this should work:
Get-MailboxFolderStatistics -Identity <MailboxID> -FolderScope Inbox | select-object Name  | foreach-object {New-MailboxExportRequest -Mailbox <MailboxID> -IncludeFolders "Inbox/$_" -FilePath \\Mypath\inbox-$_.pst }

Open in new window

Yohann JARRIERTechAuthor Commented:

We have made a step ;) but it doesn't works because of many things :

This create at least 10 exports and stop with a error :

Le nom de chaque boîte aux lettres doit être unique. Aucun nom par défaut n'est disponible pour une nouvelle demande
détenue par la boîte aux lettres 'MailboxID'. Nettoyez les demandes existantes à
l'aide de la cmdlet Remove ou spécifiez un nom unique.
    + CategoryInfo          : InvalidArgument : (Alias:MailboxOrMailUserIdParameter) [New-MailboxExportRequest], N
    + FullyQualifiedErrorId : 2C7B53A1,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest
    + PSComputerName        : ServerName

Open in new window


I think there is a problem with the variable $ _ because here is the name of the pst file created after the export : @(name=FOLDER1) knowing that the file export does not contain the mails contained in the folder (which seems obvious if the variable does not goes back not just the name of the folder but @(name=FOLDER1)
Yohann JARRIERTechAuthor Commented:
I forgot to mention that I added -BatchName "$ _" in the New-MailboxExportRequest command
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Michael PfisterCommented:
Get-MailboxFolderStatistics -Identity <MailboxID> -FolderScope Inbox | select-object Name  | foreach-object {New-MailboxExportRequest -Mailbox <MailboxID> -BatchName "$($_.Name)"  -IncludeFolders "Inbox/$($_.Name)" -FilePath \\Mypath\inbox-$($_.Name).pst }

Open in new window

timgreen7077Exchange EngineerCommented:
To Export all the sub folders of the inbox run the following:

New-MailboxExportRequest -Mailbox "user" -IncludeFolders "#inbox#/*" -FilePath \\SERVER01\PSTFileShare\subfolders.pst

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
timgreen7077Exchange EngineerCommented:
Author has any of the suggestions helped you.
timgreen7077Exchange EngineerCommented:
closing question since author no longer responds.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.