1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
#Скрипт просмотра агентов на серверах! cls $Error.clear() $servers = @("K01-CRM-TKNS01","K01-CRM-TKNS02") #$list = New-Object System.Collections.Generic.List[System.Object] $hashtable = @{} $script = {$cmd = "C:\zabbix_agent\bin\win64\zabbix_agentd.exe" $cmdex=& $cmd -V [string]$versionstring=$cmdex | Select-String "(\d\.\d\.\d)" #Write-Output "test" return $versionstring } foreach ($srv in $servers) { $srt= Invoke-Command -ComputerName $srv -ScriptBlock $script try { $hashtable.Add($srv,($srt.Substring(38,6).Trim())) } catch {Write-Host $Error} } Write-Host "Версия Zabbix агента на серверах:" $hashtable | Format-Table -Property @{Label= "Сервер"; Expression={$_.name}},@{Label= "Версия Агента"; Expression={$_.value}} -AutoSize |