Skip to main content
This site contains all sorts of collected goodies by Sean Wallbridge (SharePoint MVP) and the itgroove team and will continue to grow as times goes on.  itgroove - Victoria, BC SharePoint and Microsoft Technologies Business Consultants

Sean's SharePoint Ditty

Go Search
Home
  
Sean's SharePoint Ditty > Sean's Exchange PowerShell Reference  

Sean's Exchange PowerShell Reference

Modify settings and columns
This (living/expanding) list contains Exchange Powershell commands and scripts I've accumulated through various Google searches and I've referenced the original author, when I've been able to.
  
View: 
Sort by AttachmentsUse SHIFT+ENTER to open the menu (new window).
PowerShell CommandFilter
Functional Category
Get Display Name, Item Count, Mailbox Limit Status and Last Login for MailboxesUse SHIFT+ENTER to open the menu (new window).
Get-MailboxStatistics
Mailbox Managementhttp://www.msexchange.org/articles_tutorials/exchange-server-2007/management-administration/getting-mailbox-statistics-exchange-2007.htmlOccassionally Used
Get Mailbox attributes, in a formatted listUse SHIFT+ENTER to open the menu (new window).
Get-MailboxStatistics | fl
Mailbox Managementhttp://www.msexchange.org/articles_tutorials/exchange-server-2007/management-administration/getting-mailbox-statistics-exchange-2007.htmlOccassionally Used
Get Display Name, Total Item Size (MB) and Item Count of mailboxes, displayed nicelyUse SHIFT+ENTER to open the menu (new window).
Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft DisplayName,@{label="TotalItemSize(KB)";expression={$_.TotalItemSize.Value.ToKB()}},ItemCount
Mailbox Managementhttp://www.msexchange.org/articles_tutorials/exchange-server-2007/management-administration/getting-mailbox-statistics-exchange-2007.htmlOften Used
Send Exchange Mailbox stats (Display Name, Size and Item Count) as a scheduled EmailUse SHIFT+ENTER to open the menu (new window).
###Send mailbox statistics script

###First, the administrator must change the mail message values in this section
$FromAddress = MailboxReport@yourcompany.com
$ToAddress = administrator@yourcompany.com
$MessageSubject = "Mailbox Size Report"
$MessageBody = "Attached is the current list of mailbox sizes."
$SendingServer = "e2k7.neilhobson.com"

###Now get the stats and store in a text file
Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft
DisplayName,@{label="TotalItemSize(KB)";expression={$_.TotalItemSize.Value.ToKB()}},
ItemCount > mailboxes.txt

###Create the mail message and add the statistics text file as an attachment
$SMTPMessage = New-Object System.Net.Mail.MailMessage $FromAddress, $ToAddress,
$MessageSubject, $MessageBody
$Attachment = New-Object Net.Mail.Attachment("./mailboxes.txt")
$SMTPMessage.Attachments.Add($Attachment)

###Send the message
$SMTPClient = New-Object System.Net.Mail.SMTPClient $SendingServer
$SMTPClient.Send($SMTPMessage)

### NOTE - this section is not for including in Powershell, this is for automating scheduling of the above script ###

Run the following from the scheduler to invoke the powershell and the above script:

PowerShell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\Bin\ExShell.psc1" -Command "./sendstats.ps1"
Mailbox Management; Reportinghttp://www.msexchange.org/articles_tutorials/exchange-server-2007/management-administration/getting-mailbox-statistics-exchange-2007.htmlOften Used
How to turn on Diagnotic LoggingUse SHIFT+ENTER to open the menu (new window).
Examples:

Set-EventLogLevel “MSExchangeSA\RPC Calls” -Level High
Set-EventLogLevel “MSExchangeSA\RPC-HTTP Management” -Level High
Set-EventLogLevel “MSExchange System Attendant Mailbox\General” -Level High

See Reference Link for complete list or do the following to get all current values:

Get-EventLoglevel -server servername
Systems Administration; Server AdministrationHow to enable diagnostic logging on Exchange Server 2007Occassionally Used