Exporting and Importing Mailbox in 2010 SP1

Please trefer to any of the following links:
 
1.
 
 
OR
 
2.
 

Redistribute Exchange Databases

​To redistribute Exchange databases so they are mounted on the Mailbox Server that holds the first activation preference, run the following:
1. Open up Exchange Management Shell
2. Change the directory to the Scripts folder located in the Exchange Install Directory; 
Example: CD  “C:Program FilesMicrosoftExchange ServerV14Scripts”
3. Run the following command:
 .RedistributeActiveDatabases.ps1 -DagName <dagname> -BalanceDbsByActivationPreference –ShowFinalDatabaseDistribution –Confirm:$false
 Note: To find the DagName, you can run the get-databaseavailabilitygroup powershell command to list your Dags.

Importing pst to mailbox

Scenario: Import pst into a mailbox
Note: Must have mailbox export/import permissions to be able to do this. targetrootfolder is good if you are importing multiple psts into the mailbox. This way content is not merged under existing folders.
From Powershell, type:
New-MailboxImportRequest -Mailbox newmbox -filepath serverpstfilesnewmbox.pst-BadItemLimit 50 -T
argetRootFolder “Mailbox -newmbox”

Working with Recoverable Items Folder

​The Recoverable Items folder (known in earlier versions of Exchange as the dumpster) exists to protect from accidental or malicious deletions and to facilitate discovery efforts commonly undertaken before or during litigation or investigations
To retrieve the following quota settings:
* RecoverableItemsQuota
◦ RecoverableItemsWarningQuota
◦ ProhibitSendQuota
◦ ProhibitSendReceiveQuota
◦ UseDatabaseQuotaDefaults
◦ RetainDeletedItemsFor
◦ UseDatabaseRetentionDefaults
use this one liner:
 
Get-Mailbox “testmbox” | Format-List RecoverableItemsQuota, RecoverableItemsWarningQuota, ProhibitSendQuota, ProhibitSendReceiveQuota, UseDatabaseQuotaDefaults, RetainDeletedItemsFor, UseDatabaseRetentionDefaults
 
2.To retrieve the current size of the Recoverable items folder:
Get-MailboxFolderStatistics “testmbox” -FolderScope RecoverableItems | Format-List Name,FolderAndSubfolderSize
 
please note that quota for recoverable items folder can be raised.The default is 30GB
 
To make sure no items are deleted from the Recoverable Items folder, increase the Recoverable Items quota. You can also increase the Recoverable Items warning quota, and set the deleted item retention period to a value higher than the current size of the user’s Recoverable Items folder. This is particularly important for preserving messages for mailboxes placed on In-Place Hold or litigation hold. It’s recommended to raise these settings to twice their current size.
 
3. Increase recoverable items quota
 
Set-Mailbox “testmbox” -RecoverableItemsQuota 80Gb -RecoverableItemsWarningQuota 80Gb -RetainDeletedItemsFor 3650 -ProhibitSendQuota 80Gb -ProhibitSendRecieveQuota 80Gb -UseDatabaseQuotaDefaults $false -UseDatabaseRetentionDefaults $false
 
 
4. This example retrieves the size of the Recoverable Items folder and its subfolders and an item count in the folder and each subfolder.
Get-MailboxFolderStatistics -Identity “Mickey Mouse” -FolderScope RecoverableItems | Format-Table Name,FolderAndSubfolderSize,ItemsInFolderAndSubfolders -Auto

Search IIS logs for ActiveSync data for specific user accounts.

Scenario: You want to find ActiveSync activity for specific users that is stored in IIS logs on the Exchange Servers.

 
Using LogParser you can edit and run the following command:
 
logparser “Select * from ‘servernamec$inetpublogslogfilesw3svc1*.log’ Where cs-uri-stem LIKE ‘%Microsoft-Server-ActiveSync%’ AND (cs-uri-query LIKE ‘%username1%’ OR cs-uri-query LIKE ‘%username2%’)” -i:IISW3C -q:on >FilePathfilename.txt

Exporting Mailbox to a PST File

​Exporting mailbox to a PST File
Note: Must have the “Mailbox Import Export” role assigned
 
From powershell, type New-MailboxExportRequest -mailbox testmbox -name -filepathservernamepstfilestestmbox.pst
This will export all folders and data in each and export it into the specified PST file. Also note that the dumpster will also be exported by default.
If you want to get additional details about the mailbox export request, you can use the Get-MailboxExportRequest or Get-MailboxExportRequestStatistics cmdlet.
 
if the export fails to complete, you can add -baditemlimit for eg
 
New-MailboxExportRequest -mailbox testmbox -name -filepathservernamepstfilestestmbox.pst -baditemlimit 50

Delivery status notifications in Exchange Server

Non-delivery reports (NDRs) are system messages that report the delivery status of a message to the sender. The messages are a subclass of a general message information structure that is known as delivery status notifications. Delivery status notifications describe three kinds of situations:

  • Success (2.X.X numeric codes)
  • Persistent transient failure (4.X.X numeric codes)
  • Permanent failures (5.X.X numeric codes)

NDRs are generated when a message cannot be delivered. If the computer can detect the reason for the failed delivery, it maps the reason onto a status code, and a corresponding error message is printed. For NDRs, most numeric error codes are reported in the form of “5.X.X” and are described as permanent failures. However, certain transient conditions cause “4.X.X” codes. 

Reference:

Remove stale ActiveSync Devices from Exchange 2010

Scenario: Exchange accounts have a max of 10 ActiveSync devices per account. This script will remove stale devices that are older then 180 days.

The initial report will take hrs to run. the code is listed below. This will run and export the results to a CSV file.
$DevicesToRemove = Get-ActiveSyncDevice -result unlimited | Get-ActiveSyncDeviceStatistics | where {$_.LastSuccessSync -le (Get-Date).AddDays(“-180”)}| Export-CSV C:scriptsstaleeas.csv
The code below will remove the device by pulling the list from the CSV you created above.
import-staleeas.CSV | foreach-object {Remove-ActiveSyncDevice -Identity $_.guid -confirm:$False}