PowerShell-Exchange:Services Monitor Report
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PowerShell-Exchange:Services Monitor Report相关的知识,希望对你有一定的参考价值。
脚本地址:
脚本 Exchange Server 2010 Services Monitor - HTML Report
https://gallery.technet.microsoft.com/scriptcenter/0cd74cb6-3924-45b0-944b-a86441401094
脚本需要修改的地方:
(一)修改serverlist变量
server.txt文件里面主要是写服务器的列表地址,跟脚本放到同一个目录下就行。
cls $ServerList = Get-Content "server.txt" $report = "report.htm" Clear-Content $report
修改字符集为中文的UTF-8,否则会有乱码
Add-Content $report "<meta http-equiv=‘Content-Type‘ content=‘text/html; charset=UTF8‘>" Add-Content $report ‘<title>demo.com Exchange Service Monitor Report</title>‘
脚本的实现主要依赖get-wmiobject
foreach ($machineName in $serverlist) { $serviceStatus = get-WmiObject win32_service -ComputerName $machineName | where {($_.displayName -match "exch*") -and ($_.StartMode -match "Auto") -and ($_.StartMode -match "Manual") -and($_.state -match "Stopped")} if ($serviceStatus -ne $null) { foreach ($service in $serviceStatus) { Write-Host $machineName `t $service.name `t $service.state -ForegroundColor Red $svcName = $service.name $svcState = $service.state Add-Content $report "<tr>" Add-Content $report "<td>$machineName</td>" Add-Content $report "<td>$svcName</td>" Add-Content $report "<td bgcolor=‘#FF0000‘ align=center>$svcState</td>" Add-Content $report "</tr>" $serviceDownCount += 1 } } else { Write-Output "All Exchange related Services are running."
设置通知选项
$smtphost = "mail.demo.com" $from = "[email protected]" $to = "[email protected]" $subject = "Exchange Service Monitor"
serverlist列表里面的信息
把脚本和serverlist放到一个目录。
运行结果
本文出自 “曾垂鑫的技术专栏” 博客,谢绝转载!
以上是关于PowerShell-Exchange:Services Monitor Report的主要内容,如果未能解决你的问题,请参考以下文章
markdown Serviços - CriandouMServiço
markdown Serviços - Introdução
markdown Serviços - InjeçãodeDependência(DI)+ como usarumeserviçoemum compo
com.alibaba.dubbo.rpc.RpcException: Forbid consumer 10.254.7.50 access service com.qingmu.core.servi