Exchange Mailboxes
Exchange 2010 SP3
Disconnected Mailboxes
Get-MailboxStatistics -Database "DB 1" | Where { $_.DisconnectReason -eq "SoftDeleted" } | Format-List LegacyDN, DisplayName, MailboxGUID, DisconnectReason
Get-MailboxStatistics -Database "DB 1" | Where { $_.DisconnectReason -eq "Disabled" } | Format-List LegacyDN, DisplayName, MailboxGUID, DisconnectReason
Get-MailboxDatabase | Get-MailboxStatistics | where {$_.DisconnectReason -ne $null} | ft displayname,database,disconnectreason -auto
For reconnecting a mailbox
If the mailbox doesn't show:
Get-MailboxDatabase | Clean-MailboxDatabase
or
Clean-MailboxDatabase -Identity "DB 2"
Mailbox export to PST
New-MailboxExportRequest -Mailbox MailboxName -FilePath \\ServerName\PST\MailboxName.pst
Get-MailboxExportRequest -Name MailboxExport | fl
Get-MailboxExportRequest | Get-MailboxExportRequestStatistics
Get-MailboxExportRequest | Get-MailboxExportRequestStatistics -Identity user1
Moving mailboxes
new-moverequest -Identity "user1" -TargetDatabase "DB 1"
get-moverequest -Identity "user1"
get-moverequeststatistics -Identity "user1"
Get-MoveRequest | ?{ $_.Status -ne "Completed" -and $_.Status -ne "CompletedWithWarning" } | group targetdatabase | sort Count -Descending
Mailbox quotas
Get-Mailbox user1 | fl IssueWarningQuota,ProhibitSendQuota,ProhibitSendReceiveQuota,UseDatabaseQuotaDefaults
Disabling the mailbox but keeping the user object in AD
In the EMC, right-click and select disable mailbox or in the EMS, with Disable-Mailbox cmdlet:
Disable-Mailbox -Identity mailboxname -Confirm:$false
Disabling the mailbox will remove the Exchange attributes from the Active Direcotry object, which disconnects the mailbox and leaves the Active Directory object intact.
For some user mailbox:
get-mailbox user1 | select -expand emailaddresses alias
get-mailbox user1 | fl database
Get-MailboxPermission -Identity user1 | fl
Get-MailboxStatistics -identity user1 | fl
Get-MailboxFolderStatistics -Identity user1 -FolderScope RecoverableItems | Format-Table Name,FolderAndSubfolderSize,ItemsInFolderAndSubfolders -Auto
(From here - Clean up the Recoverable Items folder )
Get-LogonStatistics user3 | select Username, ServerName, ClientName, ApplicationId | ft -AutoSize
To find in which database a mailbox is:
((Get-Mailbox -Identity "user1@some.org").Database).DistinguishedName
Purge deleted items
(from here: Exchange 2010 - purge items in "Recover Deleted Items" )
- Add permission for admin account to the specific mailbox
- Create mail profile without cached mode and open once that mailbox in Outlook
- MFCMapi - Logon - Store table - Select that mailbox.
- Double click "mailbox - user"
- Expand "Root Container" - right click on "Recoverable Items" and select - open contents table
- Select any unwanted items - right click "delete message"
- Same in purge or deletions - contents table - delete unwanted
- Close all windows and logoff
Room Mailboxes
List room mailboxes:
Get-Mailbox | Where-Object {$_.RecipientTypeDetails -eq "RoomMailbox"} | ft -auto
New room mailbox:
New-Mailbox -UserPrincipalName room1@somedomain.org -Alias room1 -Name "Room 1" -Database "DB 4" -OrganizationalUnit "somedomain.org/Meeting Rooms" -Room
Convert a shared mailbox to a room mailbox
Remove the access group to this mailbox (if any)
Then:
Set-Mailbox mbx01 -Type Room
Add users to resouce-in-policy (if required)
Enable Resource booking attendand
Add delegates (if required)
Move the AD account to the rooms OU
List mailbox info for a database
Get-MailboxStatistics -Database "DB 4" | Select displayname, MailboxGUID, Mailbox, DatabaseName, ItemCount, TotalItemSize, LastLoggedOnUserAccount | Export-CSV mbx_stats.csv
To get a list of folders in a mailbox
Get-MailboxFolderStatistics -Identity user1 | Select Name,FolderPath,FolderSize,FolderAndSubfolderSize
Get-MailboxFolders is working only for the user who runs the command
To get a change shown faster (like some access change, reconnecting a disconnected mailbox)
Update-GlobalAddressList "Default Global Address List”
Update-OfflineAddressBook “Offline Address Book"
Update-OfflineAddressBook "Offline Address Book server1"
Update-FileDistributionService "cas1"
Update-FileDistributionService "cas2"
To create a shared mailbox (only with PowerShell in Exchange 2010)
New-Mailbox -UserPrincipalName shared1@this.domain.dfg -Alias "shared1" -Name "Shared 1" -Database "DB 4" -OrganizationalUnit "this.domain.dfg/Deps/Shared Mailboxes/" -Shared
For an access group to this shared mailbox:
Add-MailboxPermission -Identity 'CN=shared1_group,OU=Shared Mailboxes,OU=Deps,DC=THIS,DC=DOMAIN,DC=DFG' -User 'this\shared1_group' -AccessRights 'FullAccess'
Add-ADPermission -Identity 'CN=shared1_group,OU=Shared Mailboxes,OU=Deps,DC=THIS,DC=DOMAIN,DC=DFG' -User 'this\shared1_group' -ExtendedRights 'Send-as'
Convert a user mailbox to a shared mailbox
Set-Mailbox shared1 -Type shared
Convert shared mailbox to a user mailbox:
first in AD we need to set a password
then
Set-Mailbox shared1 -Type Regular