Bulk import pst files in targetrootfolders

Hi Experts,

I have 80 pst files which are all numbered with a project number.
(eg: 123.pst, 533.pst 92045653.pst etc)
I want to import alle these pst files into one mailbox.
I want each pst to be imported into a TagetRootFolder that gets the name of the pst file being imported.
(eg first pst in folder 123, second pst in folder 533 etc etc)

I can find all kinds of bulk import options oiut there, except one that accomplishes the above.

Is this possible?
LVL 2
MCSE3737Asked:
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.

Will SzymkowskiSenior Solution ArchitectCommented:
To accomplish this you will need at least Exchange 2010 SP1 in your environment. The Powershell command to use for this would be New-MailboxImportRequest. Older versions of Exchange do not have this cmdlet to accomplish exactly what you are looking for.

If you have Exchange 2010 I can assist with the powershell script.

http://exchangeserverpro.com/exchange-2010-import-pst-files-mailboxes/


Will.
0
MCSE3737Author Commented:
Hi,

I do have Exchange 2010 Version 14.3 (Build 123.4)
This is SP3 level.
My specific wish to import pst files in a folder with the same name per pst is what I would like help with.
0
Will SzymkowskiSenior Solution ArchitectCommented:
You will need to create the Outlook Folders manually. With the New-MailboxImportRequest you will have to specify the folder you want to import. If the folder does not exists I do not believe it will create it for you. You can do 1 import as a test and if it creates it for you (which i dont think it will) I can assist with the PS Script to accomplish this in bulk.
0
Redefine Your Security with AI & Machine Learning

The implications of AI and machine learning in cyber security are massive and constantly growing, creating both efficiencies and new challenges across the board. Check out our on-demand webinar to learn more about how AI can help your organization!

MCSE3737Author Commented:
-TargetRootFolder will create the folder if it does not exsist.
I also use -IsArchive, which creates the folder in the online archive.
I have 800 pst files with all different numers in the name.
What I need to accomplish is a folder for each pst.
Obviously I do not want to create them by hand.
Additional: all pst`s go in only one mailbox.
Thanks for your help on this!
0
Will SzymkowskiSenior Solution ArchitectCommented:
Glad to hear that. I will create the PST folders if they do not exist. I will create a PS script for this and post back shortly.
0
Will SzymkowskiSenior Solution ArchitectCommented:
Below is the code for the import PST script. You will also need to create a CSV file with the following headings...

CSV File Format (example)
Mailbox                FilePath                        Target
MailboxName           c:\pstfiles\1345.pst      1345
MailboxName           c:\pstfiles\77845.pst    77845
MailboxName           c:\pstfiles\1204.pst      1204
So on........

Under the Mailbox heading if you are import all PST's into the same mailbox the this value doesn't change in the CSV.

Script is below...

Import-Module activedirectory
Add-PSSnapin Microsoft.Exchange.Management.Powershell.Admin
$PSTList = Import-Csv "c:\yourCSVhere.csv"
foreach ($PST in $PSTList) {
$PST.Mailbox
$PST.FilePath
$PST.Target
New-MailboxImportRequest -Mailbox $PST.Mailbox -FilePath $PST.FilePath -TargetRootFolder $PST.Target
}

Open in new window


If you are running this script from your workstation the 2 first lines are necessary. If you are running directly on the EMS in Exchange then you can remove them.
0
MCSE3737Author Commented:
It looks like this is exactly what I want.
I will test it today and let you know.
Thank you!
0
MCSE3737Author Commented:
I am running it on an Mailbox server 2010 and put # in front of first 2 lines.
Not working and this is the result:

Cannot validate argument on parameter 'Mailbox'. The argument is null. Supply a non-null argument and try the command a
gain.
    + CategoryInfo          : InvalidData: (:) [New-MailboxImportRequest], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,New-MailboxImportRequest
0
Will SzymkowskiSenior Solution ArchitectCommented:
You also need to have Full Mailbox permissions on this mailbox as well. Also try this command below with a single PST file to rule out if it is the script or the syntax of the command.

New-MailboxImportRequest -Mailbox "MailboxName" -FilePath c:\pst\file132.pst -TargetRootFolder "132"

See if you get an error message when running that command. If it works we know that the command is working and maybe it is something with the CSV file it is reading.
0
MCSE3737Author Commented:
I had to imput a UNC path instead of c:\something.
I did the following and that works fine.
Also tried uncpaths in the ps1 and the cv, same error as before.

[PS] D:\PstFiles>New-MailboxImportRequest -Mailbox "Mike" -FilePath \\server1\d$\pstfiles\pst1.pst -TargetRootFol
der "pst1"

Name                                           Mailbox                                        Status
----                                           -------                                        ------
MailboxImport1                                 domain.intra/locUsers/Mike  Queued
0
Will SzymkowskiSenior Solution ArchitectCommented:
Yeah i have looked at the syntax again and it is correct. Not sure why it is failing. I have found a similar article which suggest trying a few things... Take a look here...

http://social.technet.microsoft.com/Forums/exchange/en-US/b6b2ca0b-81b8-4b6f-af6d-010c93ad3bbb/bulk-mailbox-export-newmailboxexportreques
0
MCSE3737Author Commented:
Hi,

Checked the sugestions following the link.
It cannot be a permission thing, ruled that out.
What fixed it in that case you linked me is creating a new CSV file.
I will try this in tomorrow morning and post what happens here.

Thank you very much for your help on this, it is much appreciated!
0
MCSE3737Author Commented:
Tried the new file no luck.
What I do see is this:
In the test csv I put 3 entries.

The failure is shown 3 times when i run it.
so it seems it is reading inside the csv

Cannot validate argument on parameter 'Mailbox'. The argument is null. Supply a non-null argument and try the command a
gain.
    + CategoryInfo          : InvalidData: (:) [New-MailboxImportRequest], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,New-MailboxImportRequest

Cannot validate argument on parameter 'Mailbox'. The argument is null. Supply a non-null argument and try the command a
gain.
    + CategoryInfo          : InvalidData: (:) [New-MailboxImportRequest], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,New-MailboxImportRequest

Cannot validate argument on parameter 'Mailbox'. The argument is null. Supply a non-null argument and try the command a
gain.
    + CategoryInfo          : InvalidData: (:) [New-MailboxImportRequest], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,New-MailboxImportRequest
0
Will SzymkowskiSenior Solution ArchitectCommented:
This is very strange, as this works with no issue in my 2010 test environment...

I will see if there is anything else i can dig up.
0
MCSE3737Author Commented:
Once again, your help is very much appreciated!
0
Will SzymkowskiSenior Solution ArchitectCommented:
I have modified the script slightly see if the below works for you...
$path = "c:\csv-files\yourCSVhere.csv"
Import-Csv -path $path
foreach {
New-MailboxImportRequest -Mailbox $_.Mailbox -FilePath $_.FilePath -TargetRootFolder $_.Target
}

Open in new window


Keep the same CSV format as shown above in my first post.
0

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
MCSE3737Author Commented:
This is the error I get at this point:

Missing opening '(' after keyword 'foreach'.
At D:\PstFiles\Import2.ps1:3 char:9
+ foreach  <<<< {
    + CategoryInfo          : ParserError: (OpenParenToken:TokenId) [], ParseException
    + FullyQualifiedErrorId : MissingOpenParenthesisAfterKeyword
0
MCSE3737Author Commented:
A colleague of mine fixed the script.
I needed to define a delimiter.
It is working perfectly now.
Thank you again for all your help

$path = "d:\PstFiles\PstFiles.csv"
$mailboxes = Import-Csv -path $path -Delimiter ";"
foreach ($Mailbox in $mailboxes) {
New-MailboxImportRequest -Mailbox $Mailbox.Mailbox -FilePath $Mailbox.FilePath -TargetRootFolder $Mailbox.Target
}
0
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
Shell Scripting

From novice to tech pro — start learning today.