Exchange 2013 PowerShell – Export a calendar to PST

If you are using a legacy deployment of Exchange 2013 and need to export either a single or a bulk of users calendars into .PST for any reason you can use the below to complete it.

Should you want to only export one user you can circumvent the $MailAddresses variable.

#This script will export ONLY Calendar information from users mailboxes in Exchange 2013 into a .pst file.
#.CSV will need only the primary SMTP Addresses of the mailboxes you wish to export.

$MailAddresses = Get-Content “C:\Calendar PST Export\Batch1.csv”

foreach ($user in $MailAddresses)

Get-MailboxExportRequest -Status Completed | Remove-MailboxExportRequest
Start-Sleep -Seconds 20

New-MailboxExportRequest -Mailbox $user -IncludeFolders “#Calendar#” -FilePath “\\ServerShare\$user.pst”

Get-MailboxExportRequest -Status Queued

Get Exchange 2013 Database and Whitespace values.

In organisations that are still using Exchange 2013, you may want to be able to differentiate between the actual size of your databases and the whitespace provisioned for your databases to use.

The below PowerShell script can be added as a Scheduled Task in order to notify your Infrastructure teams.

# This script will take the database sizes from exchange and email them to a mail address.
# First we import the exchange module.

$ExchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://<SMTPServer>/PowerShell
Import-PSSession $ExchangeSession

# Creating our array to allow string and output of command into subject.
$string = “<Org> Database Sizes – ”
$Date = (Get-Date)
$SMTPSubject =  $string + $date

# Factor in the variables for the Send-MailMessage command.

$SMTPTo = “emailrecipient@domain”
$SMTPFrom = “emailsender@domain”
$SMTPServer = “<SMTPServer>”
$SmtpBody = Get-MailboxDatabase -Status | select name, databasesize, AvailableNewMailboxSpace | Sort-Object Name | Out-String

# Then output that into a mail message.

Send-MailMessage -SmtpServer $SMTPServer -From $SMTPFrom -To $SMTPTo -Body $SmtpBody -subject $SMTPSubject