Statistics
Get-MailboxStatistics -server <ServerName>
Get a list of all mailboxes, number of items, Storage Limit Status and Last Logon Time
Get-MailboxStatistics –server <ServerName> | Sort-Object TotalItemSize -Descending | ft DisplayName,@{label=”TotalItemSize(MB)”;expression={$_.TotalItemSize.Value.ToMB()}},ItemCount, storagelimitstatus
Get the list of all mailboxes, sizes in MB, number of items and limit status. Sorted by size.
Get-MailboxStatistics -server <ServerName> | sort -Property @{expression={$_.TotalDeletedItemSize.value.ToMB()}} -Descending | select-object DisplayName, @{expression={$_.TotalDeletedItemSize.value.ToMB()};Label=”Dumpster(MB)”}, @{expression={$_.totalitemsize.value.ToMB()}; label=”Mailbox Size (MB)”}
Get the list of all mailboxes and their dumpster sizes. Sorted by dumpster size.
Get-Mailbox | Get-MailboxFolderStatistics | sort -Property {$_.FolderAndSubFolderSize.ToMb()} -Descending | where{$_.FolderType -eq “DeletedItems”} | Select-Object Identity, @{expression={$_.FolderAndSubFolderSize.ToMb()};Label=”Size of Deleted Items”}, ItemsInFolderAndSubFolders | fl
Get the list of sizes and number of items of Deleted Items for all users. Sorted by Deleted Items folder size.
If you want results to be exported into .csv file, replace | fl with | Export-Csv c:\deleted_items.csv
Get-Mailbox | Format-Table alias, *quota
Retrieves all mailbox users with mailbox quotas (only set explicitly). “unlimited” may be misleading if default quota is used. See below.
Get-Mailbox -id “**” | fl *quota*
A value of TRUE on UseDatabaseQuotaDefaults means that the per-mailbox settings are ignored and the mailbox database defaults are used.
Permissions
Get-MailboxDatabase -identity “<Database Name>” | Add-ADPermission -user <username> -AccessRights GenericAll
Full access right on all mailboxes in all databases for a user
Get-Mailboxdatabase | get-ADPermission -User admin1
List permissions admin1 has on all exchange databases
Add-MailboxPermission -identity user1 -User admin1 -AccessRights FullAccess
Grant “FullAccess” permission for admin1 on mailbox user1 (Allows to open other user’s mailbox in Outlook and OWA)
Remove-MailboxPermission -Identity user1 -User admin1 -AccessRight FullAccess -InheritanceType All
Remove FullAccess permission for admin1 on mailbox user1
Get-MailboxPermission –Identity user1
List all mailbox permissions on mailbox user1.
If information doesn’t fit in columns you can append |Format-List at the end of the command. Valid for other commands too.
Get-MailboxPermission -Identity user1 -User admin1
List all mailbox permissions admin1 have on mailbox user1
Get-ADPermission -Identity “User Name” -User admin1
List all AD permissions admin1 have on user “User Name” (“User Name” – AD Distinguished Name or Display Name (if unique) of the user, not alias)
You need this to list “Send-As” permissions as “Send-As” is AD rather than mailbox permission.
Export mailbox
Exchange 2007
Export-Mailbox –Identity <user.name> -PSTFolderPath <pathToSavePST>
Export mailbox into .pst file
Max .pst limit 20GB. Must be run from 32bit client with Exchange Management Tools and Outlook 2003 SP2 or later installed. User must be Exchange administrator.
Export-Mailbox -Identity <user.name> -StartDate “<DD/MM/YYY>” -EndDate “<DD/MM/YYY>” -PSTFolderPath C:\path\to\exported.pst
Export emails from a mailbox within specific data range. Dates are inclusive.
Requirements as above command.
Export-Mailbox -Identity <user.name> -StartDate “<DD/MM/YYY>” -EndDate “<DD/MM/YYY>” -PSTFolderPath C:\path\to\exported.pst -DeleteContent
As above, but also delete all exported messages from the Exchange database.
Export-Mailbox -Identity <user.name> -StartDate “<DD/MM/YYY>” -EndDate “<DD/MM/YYY>” -DeleteContent
Delete emails for specified data range without exporting
Exchange 2010
New-MailboxExportRequest -Mailbox <user.name> -FilePath \\server\share\FileName.pst
Export mailbox into .pst file
Exchange Trusted Subsystem must have full access to \\server\share
The user running the export request must have Mailbox Import Export role. To add run:
New-ManagementRoleAssignment -Role “Mailbox Import Export” –User domain\user.name
New-MailboxExportRequest -ContentFilter {(Received -ge ’05/01/2012′) -and (Received -le ’07/21/2012′)} -Mailbox “user.name” -FilePath “\\Server\Share\user.name.pst”
Export emails from a mailbox within a specific data range.
Requirements as above command. For more info about potential issues with this command check here.
Get-MailboxExportRequest
View all mailbox export requests. To see more info run
Get-MailboxExportRequest |fl
Get-MailboxExportRequest | where {$_.status -eq “Completed”} | Remove-MailboxExportRequest
Remove all completed export requests.
To remove all export requests, run:
Get-MailboxExportRequest | Remove-MailboxExportRequest
New-MailboxImportRequest -FilePath “\\server\share\FileName.pst” -Mailbox <user.name> -TargetRootFolder “Import”
Import a .pst file into a specified mailbox.
Requirements are the same as for New-MailboxExportRequest
-TargetRootFolder – optional parameter that specifies a folder inside the target mailbox where the items will be imported.
Exchange 2007
Exchange 2010
Leave a Reply