Hello,
i have created an custom powershell-script with xml-Output. The script checks some Windows-Services and show it in seperate channels in the Sensor. My Problem is, i don't know, how i must change my script, to execute the Script on the device, where i set-up the sensor. The script monitors actually the Services of the Probe-Server. Here is my script:
<# =================================================================================== Paessler PRTG Sensor to check Windows Services =================================================================================== Autor: My Script: Services.ps1 Version: 1.0 Date: 10.08.2020 Scriptpath: C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML Scripttype: EXE/Script Advanced #> param( [string]$ComputerName = "%host", [string]$Domain = "%windowsdomain", [string]$Username = "%windowsuser", [string]$Password = "%windowspassword", #Servicenames: [string]$ServiceName1 = "netlogon", [string]$ServiceName2 = "AppXSvc", [string]$ServiceName3 = "Dhcp" ) $xmlOutput = '<?xml version="1.0" encoding="UTF-8" ?><prtg>' if ((Get-Service -Name $ServiceName1).Status -eq 'Running'){$Count ="1"} elseif ((Get-Service -Name $ServiceName1).Status -eq 'Stopped'){$Count ="2"} elseif ((Get-Service -Name $ServiceName1).Status -eq 'Pause-Pending'){$Count ="3"} elseif ((Get-Service -Name $ServiceName1).Status -eq 'Paused'){$Count ="4"} $xmlOutput = $xmlOutput + "<result> <channel>Anmeldedienst</channel> <value>$Count</value> <valuelookup>Windows_Services</valuelookup> </result>" if ((Get-Service -Name $ServiceName2).Status -eq 'Running'){$Count ="1"} elseif ((Get-Service -Name $ServiceName2).Status -eq 'Stopped'){$Count ="2"} elseif ((Get-Service -Name $ServiceName2).Status -eq 'Pause-Pending'){$Count ="3"} elseif ((Get-Service -Name $ServiceName2).Status -eq 'Paused'){$Count ="4"} $xmlOutput = $xmlOutput + "<result> <channel>AppX-Bereitstellungsdienst</channel> <value>$Count</value> <valuelookup>Windows_Services</valuelookup> </result>" if ((Get-Service -Name $ServiceName3).Status -eq 'Running'){$Count ="1"} elseif ((Get-Service -Name $ServiceName3).Status -eq 'Stopped'){$Count ="2"} elseif ((Get-Service -Name $ServiceName3).Status -eq 'Pause-Pending'){$Count ="3"} elseif ((Get-Service -Name $ServiceName3).Status -eq 'Paused'){$Count ="4"} $xmlOutput = $xmlOutput + "<result> <channel>DHCP</channel> <value>$Count</value> <valuelookup>Windows_Services</valuelookup> </result>" $xmlOutput = $xmlOutput + "</prtg>" $xmlOutput
Add comment