Skip Ribbon Commands
Skip to main content

Sean's SharePoint Ditty

:

Sean's Exchange PowerShell Reference :All ItemsUse SHIFT+ENTER to open the menu (new window).Open MenuOpen Menu

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.
Use SHIFT+ENTER to open the menu (new window).
  
  
PowerShell Command
Functional Category
  
  
  
  
Get-MailboxStatistics
Mailbox Managementhttp://www.msexchange.org/articles_tutorials/exchange-server-2007/management-administration/getting-mailbox-statistics-exchange-2007.htmlOccassionally Used
  
Get-MailboxStatistics | fl
Mailbox Managementhttp://www.msexchange.org/articles_tutorials/exchange-server-2007/management-administration/getting-mailbox-statistics-exchange-2007.htmlOccassionally Used
  
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 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
  
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