I need to verify the version of a service running on our systems. So I have got close but cannot seem to figure it out. I am using a Get-WmiObject
process looking for the process of the service that is running. Then pull back the path of that executable that is "the" service. Then retrieve the FileVersion
of said executable file.
foreach ($Computer in $Computers ) {
$zabbix = Get-WmiObject -Class Win32_Process -ComputerName $computer -Filter "name like '%zabbix%'" |
Select -ExpandProperty Path |
Get-ItemProperty |
Select-Object -Property VersionInfo |
? {$_.ProductVersion}
}
Write-Host "$zabbix - $Computer"
Drop the ?
/ Where-Object
because you aren't filtering.
ForEach ($Computer in $Computers ){
$zabbix = Invoke-Command -ComputerName $Computer -ScriptBlock {
(Get-WmiObject -Class Win32_Process -Filter "name like '%zabbix%'" |
Select -ExpandProperty Path | Get-ItemProperty).VersionInfo.ProductVersion
}
Write-Host "$zabbix - $Computer"
}