Created
March 1, 2018 15:03
-
-
Save jazzl0ver/6972b90f0ef5afe6eca1704d3b90cd92 to your computer and use it in GitHub Desktop.
Send Exchange Server mailboxes size report
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # Add similar action to the Task Scheduler: | |
| # %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -file c:\utils\mailbox_report.ps1 | |
| # | |
| $smtpServer = "mail.server.com" | |
| $from = "[email protected]" | |
| $to = "[email protected]" | |
| $exchServer = "vm-exch16" | |
| $file = "C:\Utils\MBSizes.csv" | |
| . "C:\Program Files\Microsoft\Exchange Server\V15\bin\RemoteExchange.ps1" | |
| Add-PSSnapin Microsoft.Exchange.Management.Powershell.Admin -erroraction silentlyContinue | |
| Connect-ExchangeServer -auto | |
| Get-MailboxStatistics -Server $exchServer | Select DisplayName, ItemCount, TotalItemSize | Sort-Object TotalItemSize -Descending | Export-CSV $file | |
| $att = new-object Net.Mail.Attachment($file) | |
| $msg = new-object Net.Mail.MailMessage | |
| $smtp = new-object Net.Mail.SmtpClient($smtpServer) | |
| $msg.From = $from | |
| $msg.To.Add($to) | |
| #$msg.To.Add("[email protected]") | |
| $msg.Subject = "$exchServer: mailbox stats" | |
| $msg.Body = "Attached is the $exchServer mailbox report" | |
| $msg.Attachments.Add($att) | |
| $smtp.Send($msg) | |
| $att.Dispose() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment