Multiple Imports in ps1 file

by moxy at 2012-09-22 19:58:35


Relatively new to PS so please bear with me.

Here is the problem:
I have a number of users who I need to import into Exchange 2007 via PST from Exchange 2003. Because the PSTs need to be smaller than 2GB, each user has a number of PST files.

I have put all the import commands into one PS1 file but I’m looking for a way so that
1. I can get it torun multiple threads
2. I don’t have to say YES to each import line

Sample of ps1 file:
import-mailbox -identity -pstfolderpath c:\psts\user1-1.pst
import-mailbox -identity -pstfolderpath c:\psts\user1-2.pst
import-mailbox -identity -pstfolderpath c:\psts\user2-1.pst
import-mailbox -identity -pstfolderpath c:\psts\user2-2.pst
import-mailbox -identity -pstfolderpath c:\psts\user2-3.pst
import-mailbox -identity -pstfolderpath c:\psts\user3-1.pst
import-mailbox -identity -pstfolderpath c:\psts\user4-1.pst
import-mailbox -identity -pstfolderpath c:\psts\user4-2.pst

Thanks in advance for your help!
by DonJ at 2012-09-24 10:01:40
The second question is easier. You can probably add -confirm] to each command. I’m assuming Import-Mailbox is using the shell’s standard Yes/No confirmation prompt; if it isn’t, then my suggestion may not work.

The first question is almost as easy.

Start-Job -ScriptBlock { import-mailbox -identity -pstfolderpath c:\psts\user1-1.pst }

Will start the task in its own background thread. You can run Get-Job to monitor the status of each, and Receive-Job to receive a particular job’s results.