How to Bulk import PST files in Office 365

If migrating to Office 365 from a platform which previously used POP3, there will be a need to import all users email history into Office 365. As POP3 email is downloaded to the clients machine and this is where it all stays for the duration of it's life they traditionally get VERY BIG! In a recent migration they hav ranged from 1GB to over 30GB each.

Office 365 actually have a solutution for this, but it's not well advertised. You have to install a small client on your uploading device, log into the tenant account and then you can see the "Import" button as shown here,

Steps for Bulk PST import in Office 365

1. Populate the CSV File Provided with all of the PSTs you need to import.
O365PstImportMappingFile.csv (188B)

2. Apply the import/export permissions to the tenant account.
Excahnge GUI > Permissions > Select "Organization Management" and click Edit > Under "Roles" click on the plus symbol to "Add a role" > Select Mailbox Import Export and OK to confirm the changes.

3.Log in to the Tenant account (not as a pertner) > Import > Add > Upload files over the network
4.If not already done, Install Microsoft Azure Storage Tool with the link provided on this screen.
5. Copy the storage key and URL. KEEP THEM SAFE.
6. Start Azure Storage Tools and run:

AzCopy.exe /Source:<Source local location of PST> /Dest:"<SASURL + Folderlocation + SAS Key>" /V:AzCopylog.txt

AzCopy.exe /Source:C:\PST /Dest:"" /V:AzCopylog.txt

Everything in /Dest: and /DestSAS:needs to be in inverted commas

7. Once this is complete you can click next on the "Upload files over network" windows after checking the two check boxes.
8. Upload and validate the CSV file
9. Watch your PSTs import!

You can see all the details reporting from the Office 365 console including failed copies etc.

Administering Licenses in Office 365 via PowerShell

Manage user licences in Azure PowerShell







Get-MsolaccountSku | Where-Object {$_.SkuPartNumber -eq "EnterprisePack"} | ForEach-Object {$_.ServiceStatus}

Get-MsolaccountSku | Where-Object {$_.SkuPartNumber -eq



List of all users

Get-MsolUser -all


Export list of user licences

Get-MsolUser -all | ft displayname, islicensed | Out-File "C:\UserLicences.csv"

Get Licensed users results


Set a users usage location (Required before assigning a licence)

Set-MsolUser -userprincipalname [email protected] -useagelocation "GB"


Assign a licence to a user

Set-MsolUserLicence -userprincipalname [email protected] -AddLicenses "TeamRou:EnterprisePack"

Assigne licenses results


Remove a licence from a user

Set-MsolUserLicence -userprincipalname [email protected] -Removelicences "CBTNuggets346:EnterprisePack"


Remove licenses results

Bulk Mailbox Creation

CSV template for this script is attached to this post named "Template.xls"


To create mailboxes all with the same password:

$database = Get-MailboxDatabase

$Password=Read-Host “Enter Password” –AsSecureString


Import-CSV CreateMailboxes.csv | ForEach {New-Mailbox -Alias $_.alias -Name $ -userPrincipalName $_.UPN -Database $database -OrganizationalUnit Users -Password $Password} -ResetPasswordOnNextLogon $true



To create mailboxes with custom passwords:


Import-CSV D:\Scripts\Bulk Mailbox Creation\users.csv | ForEach {New-Mailbox -Alias $_.alias -Name $ -userPrincipalName $_.UPN -Database “Mailbox Database” -OrganizationalUnit Users -Password

(ConvertTo-SecureString $_.password -AsPlainText -Force)}

Template.xlsx (10.7KB)

Disabling, Removing and Reconnecting Mailboxes



Disabling a mailbox disconnects the mailbox from the user account. 






Removing a mailbox disconnects that mailbox from the user account and removes it from Active Directory






Go to the disconnected mailbox node, find mailbox and right click > connect > Select user account.




Connect-Mailbox –Identity "Jesper Herp" –Database "MBX-DB-ONE" –User "Jesper Herp"




Get all Disconnected Mailboxes


$Database = Get-Mailboxdatabase

Get-Mailboxdatabase | Get-MailboxStatistics | Where-Object {$_.DisconnectDate -Notlike $NULL} | FL DisplayName, DisconnectDate, MailboxGuid


Take the GIUD of the mailbox to delete:


Remove-Mailbox -Database $Database -StoreMailboxIdentity def4aabd-2156-5857-858f-470efc3e6f28

Bulk Active Directory Import

CSVDE -i -f c:\users.csv


To Loop a DSAdd command


for /f "Tokens=*" %i in (c:\5000users.csv) do dsmod user %i -pwd Pa$$w0rD -disabled no