花了一上午,合成的一个粗糙的IT用来了解EXCHANGE运行情况的自动邮件脚本
2013-04-19 15:59
323 查看
看着简单,格式不好。
但也让IT能了解EXCHANGE 2010的MAIL DATABASE的空间占用,WHITE SPACE闲置空间情况,每个用户占用的大小。
代码也使用了输出为HTML,发送多个邮件,同时发送多个HTML作EMAIL BODY。因为附近毕竟要打开多次。
原始参考贴及后续操作:
http://www.mikepfeiffer.net/2010/03/exchange-2010-database-statistics-with-powershell/
Then you could schedule the .ps1 script to run as needed. So let’s say you saved the above code to c:\dbreport.ps1, you could schedule the following command to run on the server:
If you aren’t already familiar with scheduling Exchange 2010 PowerShell scripts check out this post.
输出样本:
但也让IT能了解EXCHANGE 2010的MAIL DATABASE的空间占用,WHITE SPACE闲置空间情况,每个用户占用的大小。
代码也使用了输出为HTML,发送多个邮件,同时发送多个HTML作EMAIL BODY。因为附近毕竟要打开多次。
原始参考贴及后续操作:
http://www.mikepfeiffer.net/2010/03/exchange-2010-database-statistics-with-powershell/
Then you could schedule the .ps1 script to run as needed. So let’s say you saved the above code to c:\dbreport.ps1, you could schedule the following command to run on the server:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; c:\dbreport.ps1"
If you aren’t already familiar with scheduling Exchange 2010 PowerShell scripts check out this post.
function Get-DatabaseStatistics { $Databases = Get-MailboxDatabase -Status foreach($Database in $Databases) { $DBSize = $Database.DatabaseSize $MBCount = @(Get-MailboxStatistics -Database $Database.Name).Count $MBAvg = Get-MailboxStatistics -Database $Database.Name | %{$_.TotalItemSize.value.ToMb()} | Measure-Object -Average New-Object PSObject -Property @{ Server = $Database.Server.Name DatabaseName = $Database.Name MailboxCount = $MBCount "DatabaseSize (GB)" = $DBSize.ToGB() "AverageMailboxSize (MB)" = $MBAvg.Average "WhiteSpace (GB)" = $Database.AvailableNewMailboxSpace.ToGB() } } } Get-DatabaseStatistics | ConvertTo-HTML | Out-File c:\autops1\report.html Get-MailboxStatistics -Database "AAA" | Select DisplayName, ItemCount, TotalItemSize | Sort-Object TotalItemSize -Descending | ConvertTo-HTML | Out-File c:\autops1\AAA.html 。。。。 Get-MailboxStatistics -Database "BBB" | Select DisplayName, ItemCount, TotalItemSize | Sort-Object TotalItemSize -Descending | ConvertTo-HTML | Out-File c:\autops1\BBB.html $recipients = "AAA <AAA@>", "BBB <BBB@>", "CCC <CCC@>" $htmlfile = "c:\autops1\report.html", "AAA.html",..."c:\autops1\CCC.html" Send-MailMessage -To $recipients -From EEE@com -Subject " Exchange Database Statistics for $((get-date).ToShortDateString())" -SmtpServer D.D.D.D -BodyAsHtml (Get-Content $htmlfile | Out-String)
输出样本:
相关文章推荐
- 一个监控Squid运行进程数并自动重启的简洁Shell脚本分享
- 一个监控Squid运行进程数并自动重启的简洁Shell脚本分享
- 朋友的一个问题:Linux开机如何自动运行自己编写好的shell脚本
- 一个python的邮件发送脚本,自动,定时,可以附件发送,抄送
- linux下收集系统硬盘,内存使用情况以定时邮件方式发给root的一个脚本
- 用Shell编程写一个能实现自动安装目录和运行游戏的脚本
- 树莓派把一个python脚本作为服务运行,配置开机自动启动
- Tracker 是一个运行于浏览器书签栏的 JavaScript 嗅探工具,她将被启动于其他网页之后,为了协助您了解目标网页中 JavaScript 的运行情况
- 如何避免Docker容器启动脚本运行后自动退出——一个cron定时任务docker镜像方案
- 硬盘检测的一个shell脚本及自动重启自动运行脚本
- Shell脚本实例(一) 监控一个程序的运行情况
- Linux crontab的使用方式,sh脚本的编写,sh脚本自动启动tomcat服务器,sh监控系统运行情况
- 让一个脚本自动定时运行,设置、启动 linux定时脚本 (crontab详解)
- 一个python的邮件发送脚本,自动,定时,可以附件发送,抄送,附有说明文件 (本脚本是python的2.7.x环境下可用)
- 使用Excel宏录制了解VBA的API以及文件打开自动运行脚本
- Exchange 2010 处于禁止发送用户自动收到来自IT的提醒邮件,而邮箱因为达到最大数据量被禁用的处理及对邮箱数据的清理!
- 一个python的邮件发送脚本,自动,定时,可以附件发送,抄送,附有说明文件
- 一个python的邮件发送脚本,自动,定时,可以附件发送,抄送,附有说明文件
- 一个用来自动管理大容量表的Sql脚本
- Linux crontab的使用方式,sh脚本的编写,sh脚本自动启动tomcat服务器,sh监控系统运行情况