How to Export Exchange Mailbox to PST File with PowerShell

If you are an Exchange administrator, you may need to export mailboxes to PST files for various reasons, such as backup, migration, compliance, or archiving. For example, an employee leaves the organization and you want to archive the mailbox to a PST file. By default, no user can import and export PST files in Exchange Server. Before you can do this, you need role permissions. In this blog post, you will learn how to export Exchange mailbox to PST file format with PowerShell.

Edit Mailbox Import Export role permissions

The Import Export role for Mailbox allows administrators to import and export mailbox content and clean unwanted content from a mailbox. Therefore, we need access to the Import Export role. Without access, we cannot export PST files from Exchange Server.

Get Mailbox Import Export Role

Let’s use the Get-ManagementRoleAssignment cmdlet to view who is assigned the Mailbox Import Export role.

C:\>Get-ManagementRoleAssignment -role "Mailbox Import Export" -GetEffectiveUsers | ft -AutoSize
Mailbox import export role assignment 3 PST File

If you want to filter the result, we can filter by account name.

C:\>Get-ManagementRoleAssignment -role "Mailbox Import Export" -GetEffectiveUsers | Where { $_.EffectiveUserName -like "User_Name_Enter" } | ft -AutoSize
Mailbox import export role assignment1 PST File

Add to role assignment specific user.

C:\>New-ManagementRoleAssignment -Role "Mailbox Import Export" -User "Jane" | ft -AutoSize
Mailbox import export role assignment2 PST File

The user was successfully assigned to the Mailbox Import Export role. Verify the permission.

Mailbox import export role assignment3 PST File

Remove Mailbox Import Export Role

For security reasons, it’s a good idea to remove the permissions after you’re done exporting the mailbox to PST.

C:\>Get-ManagementRoleAssignment -Role "Mailbox Import Export" | Where { $_.EffectiveUserName -like "Jane" } | Remove-managementRoleAssignment
Mailbox import export role assignment5 PST File
Mailbox import export role assignment6 PST File

Create a Sharing Folder for the PST File Export

When exporting mailbox data as a PST file, it needs to be saved in a share folder. We will create a folder with the correct permissions. I have created a folder with the name PST on the D drive of the computer.

Right click on the PST folder we created, click properties and then click Sharing > Advanced Sharing.

Sharing folder create1 PST File

After checking “Share this folder”, click on the “Permissions” button.

Sharing folder create2 PST File

After clicking the Add button, we write the “Exchange Trusted Subsystem” and “SYSTEM” groups in the “Enter the object names to select” section.

Sharing folder create3 PST File
Sharing folder create4 PST File

We give “Change” and “Read” permissions for “Exchange Trusted Subsystem” group and “Full Control” permission for “SYSTEM” group and click OK button.

Sharing folder create5 PST File
Sharing folder create6 PST File

Export Exchange mailbox to PST File with PowerShell

We use the Get-Mailbox command to display the display names of users.

Get PST File
C:\>New-MailboxExportRequest -Mailbox "caner" -FilePath "\\Exc01\pst\caner.pst"
NewMailboxExportRequest to PST file PST File

Check the Status of Export Mailbox to PST

Export Mailbox status is displayed.

C:\>Get-MailboxExportRequest | Get-MailboxExportRequestStatistics
get PST File

Mailbox Export status displays the size moved in the migration time.

C:\>Get-MailboxExportRequestStatistics caner | ft SourceAlias,OverallDuration,EstimatedTransferSize,BytesTransferred
get mailboxexportrequeststatistics1 PST File

Image of the PST file in the \Exc01\pst\ directory.

PST file PST File

Export All Exchange mailbox to PST

Bulk export Exchange mailboxes to PST file commads.

C:\>$alluser = Get-Mailbox
C:\>foreach($Mailbox in $alluser){New-MailboxExportRequest -Mailbox $Mailbox.Alias -FilePath "\\Exc01\pst\$($mailbox.alias).pst"}
All mailbox export pst PST File

Clear the completed export request.

C:\>Get-MailboxExportRequest -Status Completed | Remove-MailboxExportRequest
PST File

Conclusion

In this blog post, we have shown you how to export Exchange mailbox to PST file format. We hope this post was useful and informative for you.

You can find our other Exchange Server related content here.

Caner

Leave a Reply

Your email address will not be published. Required fields are marked *

Next Post

ftp Server in Linux Ubuntu Server 22.04

Fri Apr 14 , 2023
FTP (File Transfer Protocol) is a standard way of transferring files between computers over a network. FTP allows you to upload and download files, create and delete directories, and manage file permissions on a remote server. In this blog post, I will show you how to enable FTP server on […]
FTP Server in Linux Ubuntu Server 22.04

You May Like