Script to import PST’s into a mailbox by first automatically finding the PST file location

Scenario:  You have a list of PST files that you want to import into a mailbox. You want to place the imports into a folder in the mailbox called ‘Imported’ so it doesn’t conflict with the users current mailbox folder structure.

Here is what you have:

  1. A list of users in .csv format with the csv header of NAME
  2. The PST files located in a directory (or multiple sub directories) with the users name in the PST files.
  3. Exchange Powershell!

Script: The script below will take the list of users in the csv format, loop through each user to find their PST’s. For each PST it will create a New Mailbox Import Request. Note – Make sure your properly plan space as you could potentially blow up your database/log size.

#Import the users from the CSV File
$users = Import-csv C:tempusers.csv

#Loop through each user
$users | %{
$u = $_ | Select -ExpandProperty Name

#Find the PST files for the user in this loop    
$files = get-childitem \FileServer1SharePSTs -file $u* -Recurse

#For each PST file, Create a Mailbox Import Request
    $files.fullname | %{
    New-mailboximportrequest $u -filepath $_ -acceptlargedataloss -baditemlimit 100000 -batchname BigImport -targetrootfolder Unarchived
                       }
}

 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: