원격 컴퓨터에서 서비스 목록을 모니터링하고 싶습니다. 이러한 서비스는 모든 원격 시스템에서 동일하지 않습니다.원격 컴퓨터의 서비스 목록을 모니터링하는 방법은 무엇입니까?
내가 가진 가장 가까운 것은 원격 컴퓨터에서 중지되는 모든 서비스를 모니터링하는 것이지만 서비스 목록을 모니터하는 방법을 스크립트하는 방법을 찾는 것 같습니다.
$Date = Get-Date -Format dd-MMM-yyyy
$Time = Get-Date -Format "hh:mm:ss tt"
$Style = @"
<!DOCTYPE html>
<html>
...
"@
$ServerList = Get-Content -Path C:\temp\computers1.txt
$body = $ServerList |
Foreach-Object {
Get-Service -ComputerName $_ | Where-Object {
$_.Status -ne "Running" -and
$_.StartType -like "Automatic"
}
} |
Select-Object MachineName, Status, DisplayName, StartType |
Sort-Object -Property MachineNAme -Descending |
ConvertTo-Html
$colorTagTable = @{
Stopped = ' bgcolor="#ff0000">Stopped<';
Running = ' bgcolor="#00ff00">Running<'
}
# get possible values look them in text sorrounded by > < and replace
# them with style (pun intended).
$colorTagTable.Keys | foreach {
$body = $body -replace ">$_<", ($colorTagTable.$_)
}
ConvertTo-Html -Head $Style -Body $body | Out-File "C:\temp\srv.htm"