Script repository
The script exports the contents of an Exchange mailbox archive to a Personal Storage Table (PST) file. To execute the script, create a business rule, custom command or scheduled task configured for the User object type.
To be able to export mailbox archive, the Adaxes service account (specified during the software installation) must be assigned the Mailbox Import Export role in Exchange.
Parameters
$exchangeServer- the fully-qualified domain name (FQDN) of the Exchange server.$filePath- the path to the PST file that will be created by the script.
$exchangeServer = "exchangeserver.domain.com" # TODO: modify me
$filePath = "\\server\share\Archive\%username%.pst" # TODO: modify me
try
{
# Connect to the Exchange server
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionURI "http://$exchangeServer/PowerShell"
Import-PSSession $session -DisableNameChecking -AllowClobber -CommandName "Get-MailboxExportRequest", "Remove-MailboxExportRequest", "New-MailboxExportRequest"
# Clear all previous export requests with the same name.
Get-MailboxExportRequest -Name "%username%" | Remove-MailboxExportRequest -Confirm:$False
try
{
# Initiate export of the mailbox archive.
New-MailboxExportRequest "%username%" -FilePath $filePath -Name "%username%" -IsArchive -ErrorAction Stop
}
catch
{
$Context.LogMessage("Failed to initiate export of mailbox archive for %username%. Error message: " + $_.Exception.Message, "Warning")
}
}
finally
{
# Close connection to the Exchange server.
if ($session) { Remove-PSSession $session }
}
Comments 2
You must be signed in to comment.
KVM
We get this error when running the script above, what should we use to sequentially get ever users mailbox archive to export?
Failed to initiate export of mailbox archive for %username%. Error message: The operation couldn't be performed
because '%username%' couldn't be found.
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException
+ PSComputerName : localhost
Support
Hello,
Could you, please, specify how exactly you are executing the script? A screenshot of the Custom Command, Scheduled Task or Business Rule executing the script would be much appreciated. You can send it to our support email support[at]adaxes.com.
Also, could you provide us with the exact script you are using with all the modifications in TXT format?