Export list of Mailboxes to PST in Exchange Server 2010 -SP3 RU8v2.

Hi Everyone.

Every month we have to  export around 50 to100 mailbox to PST for users leaving process and the below command we use to export for each users manually.

Command : New-MailboxExportRequest -Mailbox AylaKol -FilePath \\MBX-01\PSTFileShare\Ayla.pst

I would like to export the list of  user's mailbox using a script and I got the below commands from another forum  and tried  to export with 2 test mailboxs.

Mailbox were queued as mentioned below,But the result is only one .pst file generate named ".PST".

[PS] C:\>$Export = Get-Content .\Users\exadmin\Desktop\Mailbox.txt

[PS] C:\>$Export|%{$_|New-MailboxExportRequest -FilePath "\\servername\D$\Export\PST\$($_.alias).pst"}

Name                                       Mailbox                                                         Status

----                                           -------                                                              ------

MailboxExport                         ch.india.com/Non ch accounts/Users/Ram...    Queued

MailboxExport                         ch.india.com/Non ch accounts/Users/Kha...     Queued

Please advise if I need to change any think in the command or kindly share any script

Thanks.
February 2nd, 2015 9:44am

Hi Amjath,

you can't use the previous automatic $_ variable behind a pipeline-"|". Here's a slight rewrite that ought to work:

# Get list of Mailboxes
$Export = Get-Content .\Users\exadmin\Desktop\Mailbox.txt

# For each mailbox start an Export request
foreach ($mb in $Export) { $mb | New-MailboxExportRequest -FilePath "\\servername\D`$\Export\PST\$mb.pst"}

Cheers,

Free Windows Admin Tool Kit Click here and download it now
February 2nd, 2015 9:59am

Hi Fred,

No luck.

only one .pst file generated in the given file path

Thanks.

February 2nd, 2015 11:14am

Hi Amjath,

found the error in above code (both yours and mine):

In the filepath parameter we user $mb.Alias for the filename. That is wrong, because $mb is a simple string, not an actual mailbox. I edited my previous post, the code should now work for any amount of Mailboxes.

Cheers,
Fred

Free Windows Admin Tool Kit Click here and download it now
February 3rd, 2015 2:50am

Prefect script Fred. Youre awesome

 

Thanks a lot !

February 3rd, 2015 11:42pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics