I recently had a need to export mailboxes to PST. This was done in an environment with Exchange 2010.
This can easily be done with the following command in the Exchange Management Shell.

New-MailboxExportRequest -Mailbox  -FilePath \serverPSTIdentity.pst

This is a bit inconvenient if you need to export more than a few mailboxes.
I created the script below to accommodate my need and to be able to run it from another workstation.
The only requirement is that you have access to the Exchange server and that you have the management tools installed for your version of Exchange.

As soon as I can get around to it I will test this on Exchange 2013 and maybe a version for Exchange Online.

    <#
    .SYNOPSIS
    Use this script to export one or more mailboxes to a UNC path. This is verified on Exchange 2010. 
    .DESCRIPTION
    To make this work you need to create a share on a server and give read/write permissions to the group "Exchange Trusted Subsystem".
    To run this on a workstation you need to install the management tools for Exchange.
    .PARAMETER CSV
    The path to where your CSV-file is located.
    .PARAMETER PSTShare
    The UNC-path where you want the exported PSTs to be stored.
    Note that the security group "Exchange Trusted Subsystem" need permission to write to this share.
    .PARAMETER ExchangeServer
    FQDN of your Exchange server.
    .EXAMPLE
    Export-PST.ps1 -CSV c:users.csv -PSTShare \localhostPST -ExchangeServer MyServer.domain.local
    This will export the mailboxes of all the users in your CSV.
    .DISCLAIMER
    All scripts and other powershell references are offered AS IS with no warranty.
    These script and functions are tested in my environment and it is recommended that you test these scripts in a test environment before using in your production environment.
    #>
[CmdletBinding()]
param(
    [Parameter(Mandatory=$True)]
    

[string]

$CSV, [Parameter(Mandatory=$True)]

[string]

$PSTShare, [Parameter(Mandatory=$True)]

[string]

$ExchangeServer ) BEGIN{ #Checks if the user is in the administrator group. Warns and stops if the user is not. If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(` [Security.Principal.WindowsBuiltInRole] “Administrator”)) { Write-Warning “You are not running this as local administrator. Run it again in an elevated prompt.” Break } } PROCESS{ try { $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://$ExchangeServer/PowerShell/ -Authentication Kerberos Import-PSSession $Session } catch { Write-Host “Error while importing session to $ExchangeServer” } $Users = Import-Csv $CSV foreach($User in $Users){ try{ $Identity = $User.Identity New-MailboxExportRequest -Mailbox $User.Identity -FilePath $PSTShare$Identity.pst } catch{ Write-Host “Error while exporting $User” } } } END{ Remove-PSSession $Session }

Leave a Reply