PowerShell-Exchange:Services Monitor Report
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."
页:
[1]