Import PST Office 365 PowerShell
Hello,
Microsoft allows you to import PST files into your Exchange Online mailboxes with “Import Service”. This service is currently under public preview but it was very stable when I tested it.
Before you begin, there are some prerequisites:
- Have an admin account on your Office 365 tenant
- Have “Import Export Mailbox” admin rĂ´le
- High upload bandwidth is a appreciated bonus
Import PST Office 365 PowerShell – Storage Provisioning
This service is based on an Azure Storage created by Microsoft that you can use to store the PST before importing them into your mailboxes.
For the first import, the Storage Account will be created, it may take a few minutes, and you may want to give it two shots before it gets created.For that, you need to click on “Show network upload SAS URL”. This URL will contain a few things:
- Storage Account Name
- Container Name
- Shared Access Signature
Here an example :
https://dd092cec1d084ab8b190526.blob.core.windows.net/ingestiondata?sv=2012-02-12&se=2017-02-05T13%3A33%3A07Z&sr=c&si=IngestionSasForAzCopy201611212055520769&sig=aeBqKqsMilU8PDHueVj3Q4c5hkgE%3D
- dd092cec1d084ab8b190526 is the storage account name
- ingestiondata is the container name
- ?sv=2012-02-12&se=2017-02-05T13%3A33%3A07Z&sr=c&si=IngestionSasForAzCopy201611212055520769&sig=aeBqKqsMilU8PDHueVj3Q4c5hkgE%3D is the Shared Access Signature
The Shared Access Signature is composed of
- sv: Storage Service Version
- se: Expiration date
- sr: Storage type (Container/Blob)
- si: Storage Identifier
- sig : Signature
This is the URL that will be used by the AzCopy/Azure Storage Explorer tool to upload PST.
Note: The URL may change overtime, but only the Shared Access Signature part, indeed, the link is valid for ~60 days.
Import PST Office 365 PowerShell – Upload PST
Once you got the Storage Provisioned, you can start the upload process.
For this step, you have a choice for the tool, you can use AzCopy, it’s the command line tool, or Azure Storage Explorer, it’s the graphical one.
They both work well, the choice is up to you.
AzCopy
AzCopy.exe /Source:D:PSTs /Dest:"https://dd092cec1d084ab8b190526.blob.core.windows.net/ingestiondata?sv=2012-02-12&se=2017-02-05T13%3A33%3A07Z&sr=c&si=IngestionSasForAzCopy201611212055520769&sig=aeBqKqsMilU8PDHueVj3Q4c5hkgE%3D" /Pattern:1gb.pst
Note : You need to use AzCopy version 5.2 ho higher or you’ll get some 404 errors:
Failed to validate destination: One or more errors occurred. The remote server returned an error: (404) Not Found. The specified resource does not exist.
Azure Storage Explorer
And now, you can use the tool to import some PST :
Note: You can check the list of files present on Azure with this PowerShell line (require Azure.Storage module):
New-AzureStorageContext -SasToken ($SharedAccessSignatureURL -split '\?' | Select-Object -Last 1) -StorageAccountName ($SharedAccessSignatureURL -split '\.' -split '//')[1] | Get-AzureStorageBlob -Container ($SharedAccessSignatureURL -split '\?' -split '/')[3] | Select-Object -ExpandProperty Name
Import PST Office 365 PowerShell – Mapping file
Once the PST uploaded to the Azure Storage, you need to build a CSV file that will map PST files to mailboxes and destination folder, here under a example from my tests:
Workload,FilePath,Name,Mailbox,IsArchive,TargetRootFolder,ContentCodePage,SPFileContainer,SPManifestContainer,SPSiteUrl Exchange,,3gb.pst,Anakin.Skywalker@itfordummies.net,FALSE,/,,,, Exchange,,1gb.pst,Darth.Vador@itfordummies.net,TRUE,/,,,,
You really need to keep the structure of the file, the case is kind of sensitive for the “FALSE” or “TRUE”, and for the PST file name.
Note: The users came from this blog post.
Import PST Office 365 PowerShell – Import
This is the final step, you just need to import the PST mapping file, and let the import run.
Hit “Finish”, and you’re done. The import will progress on Microsoft side, you can keep an eye on the progress with the details of the batch job or with :
Get-MailboxImportRequest | ForEach-Object -Process { Get-MailboxImportRequestStatistics -Identity $_.RequestGuid } | Select-Object -Property BatchName, TargetAlias, StatusDetail, StartTimestamp, OverallDuration,TotalInProgressDuration,EstimatedTransferSize,PercentComplete,@{Label='File';Expression={$_.AzureBlobStorageAccountUri | Split-Path -Leaf}} | Out-GridView -Title "PST Import Progress
From my personal experience, you can expect ~1gb/hour of import speed.
Pingback: Prevent PST Usage Growth PowerShell - It for DummiesIt for Dummies
Pingback: Export Contacts Calendar Mailbox PowerShell - It for DummiesIt for Dummies