Start Exchange Server PST Import Or Mailbox Move Using A PowerShell Timer

This blog post will show you how to use PowerShell to schedule a PST mailbox migration or mailbox move using PowerShell timer without using a Schedule task.

The code below Is configured to start a PST Import Migration after 4 hours.

To change the start time change the value in the $max variable

If you need to send an email confirmation with the status of the PST Import use the 3 lines at the end of the code (make sure you change the email and SMTP server).

### CODE START

if ( (Get-PSSnapin -Name Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction SilentlyContinue) -eq $null )

{

add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010

}

$max = 14400

for ($i=$max; $i -gt 1; $i–)

{

Write-Progress -Activity “Counting Down” -Status “Countdown” -SecondsRemaining $i

Start-Sleep 1

}

New-MailboxImportRequest NAME -targetRootFolder “inbox/PST” -FilePath \\SHARE\PST\NAME.pst        -ExcludeFolders “#contacts#”, “#calendar#”

## EMAIL Confirmation optional (Delete 3 lines below If you don’t need email confirmation)

Start-Sleep 100

get-MailboxImportRequest > log2.txt

Send-MailMessage -From [email protected] -To [email protected] -SmtpServer SERVER -Subject “PST Migration Started” -Body “See attachment” -Attachments log2.txt

### END CODE

This is how the Counter looks when using ISE.

This script will work with Exchange 2010, 2013 and Exchange 2016