Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

How to queue up pst imports from a text file of user names?

$
0
0

I'd like to use this script to import all pst files located in the users "outlook files" folder into their corresponding archive mailboxes.  Many users have more than a single pst file to import, so the more simple one line command to import psts will not work.  We have the users copy all the psts into a single folder and the script imports all the pst file found in the folder whether it is one pst file or several.

$filepath = "\\server\share\username\documents\outlook files folder\"

$items = Get-ChildItem -Path $filepath -Filter *.pst

 

foreach ($item in $items) {

 

    $location = Join-Path -Path $filepath -ChildPath $item.Name

   

    New-MailboxImportRequest -Mailbox username -IsArchive -FilePath $location

   

 

}

 

If I had a text file with a list of 30 user names such as:

jbond

jsmith

mjones

kchang

What is the syntax to pull the usernames from a text file and substitute the word "username" for the actual user name in the share name and the mailbox username/alias in the mailboximportrequst and the mailbox import label, complete the pst import using the new-mailboximport command (naming the mailbox import (mailboximportusername, mailboximportusername1 etc. (instead of just mailboximport, mailboximport1), then start a new mailbox import request for the next name and so on until it gets to the last name? 










Viewing all articles
Browse latest Browse all 7132

Trending Articles