This script creates a folder for each PST file with the name: "Import (
Prereqs for the script are:
* For each user with to be imported PST files create a folder with the first part of the emailadres (everything in front of the @-sign)
* add the PST files in the appropriate folder
* Edit the first two lines of the script to point to the share where the data resides, and the domainname with the @-Sign
* User must have the Import and Export management role assigned
# PST Import script. # Bas Steelooper, XOBIT IT Services # # This script will import the PST files from a given location. # The PST files must reside in a folder which is named as the part of the emailadres in front of the @-sign # # This script will import each folder one at a time and cleanup all the completed imports # With the command Get-MailBoxImportRequest you can view all the failed import requests # Configure the parameters. # $pstpath contains the share location where the PST Files are stored. ( The AD Computer account must have access to this location) # $emaildomain contains the rest of the emailadres for all users # $forceimport if $TRUE thePST-File will be forced imported, items which cannot be imported are skipped. Default is $FALSE $pstpath = "\\<server>\<share>\UsersPSTData" $emaildomain = "@steelooper.com" $forceimport = $TRUE #============================ # Do not edit below this line #============================ #Load the Exchange powershell Snap-IN Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 get-ChildItem $pstpath | Foreach-object{ $curuser = "" $curuser = $_ $PSTFiles = get-ChildItem $pstpath\$curuser $PSTFiles | Foreach-Object{ if ($forceimport) { New-MailboxImportRequest -BatchName $curuser -BadItemLimit 200 -AcceptLargeDataLoss -Name $_ -MailBox $curuser$emaildomain -FilePath $pstpath\$curuser\$_ -TargetRootFolder "INBOX/Import ($_)" } else { New-MailboxImportRequest -BatchName $curuser -Name $_ -MailBox $curuser$emaildomain -FilePath $pstpath\$curuser\$_ -TargetRootFolder "INBOX/Import ($_)" } } while ((Get-MailboxImportRequest -BatchName $curuser | Where {$_.Status -eq "Queued" -or $_.Status -eq "InProgress"})) { sleep 60 } Get-MailboxImportRequest -BatchName $curuser | Where {$_.Status -eq "Completed"} | Remove-MailboxImportRequest -Confirm:$false; }
No comments:
Post a Comment