Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Check for existance of a service

$
0
0

Hi all,

I trying to write a script that checks for the existance of a service and will output only the servers that do not have that service running on it to a text file. Here's what I'm starting with but I'm not able to get the filters working right.

 

# Path to computers.txt file containing a list of servers to check
$names = gc "C:\SCRIPTS\allservers.txt"
# Loop through server list
foreach($name in $names) {
# Check status of the server service
  $name
  Get-WMIObject Win32_Service -computer $name | Where { $_.Name -eq "Zabbix Agent" }
}

 

Thanks in advance


Viewing all articles
Browse latest Browse all 6937

Trending Articles