Get-ZabbixAgent.ps1
function Get-ZabbixAgent { <# .SYNOPSIS Returns Zabbix Agent. .DESCRIPTION Queries for "Zabbix Agent" service on remote computer .EXAMPLE Get-ZabbixAgent -Server Agent1 | Restart-Service Restarts Zabbix Agent on remote server. #> [CmdletBinding()] param ( [Parameter(Mandatory = $true, Position = 0)] [Alias('Server')] [System.String] $Computer ) #$agent = Get-Service "Zabbix*" -ComputerName $Server #return $agent $agent = Get-WmiObject -Class win32_service -ComputerName $Computer | Where-Object -FilterScript { $_.Name -like '*zabbix*' } if ($agent) { $exePath = ($agent.PathName -split "--")[0] $confPath = ($agent.PathName -split "config")[-1].Trim() $agent | Select-Object -Property Name, DisplayName, State, @{E={$agent.PathName};L="exeString"}, @{E={$exePath};L="exePath"}, @{E={$confPath};L="confPath"} } ELSE { # Agent not found. Throw error Write-Error "Zabbix Agent Service Not Found" } } |