我正在监视每个CAS服务器的连接计数,并希望将每个服务器的输出连接起来,以便我可以干净地显示它。
我已经尝试了“添加”结果,如$ rpc = $ rpc + XXXCommandHereXXX和pipe道,如下所示,但我无法“join”命令。
$rpc = (get-counter -ComputerName NYCEXCAS01 -Counter "RPC/HTTP Proxy\Current Number of Incoming RPC over HTTP Connections").countersamples | Select-Object Path, CookedValue $rpc | (get-counter -ComputerName NYCEXCAS02 -Counter "RPC/HTTP Proxy\Current Number of Incoming RPC over HTTP Connections").countersamples | Select-Object Path, CookedValue
我想做一些逻辑上不合理的事吗?
不要在每个Get上执行Select-Object 。 那么你应该没有问题“添加”集合和稍后Select所需的属性:
$a = (get-counter -ComputerName NYCEXCAS01 -Counter "RPC/HTTP Proxy\Current Number of Incoming RPC over HTTP Connections").countersamples $b = (get-counter -ComputerName NYCEXCAS02 -Counter "RPC/HTTP Proxy\Current Number of Incoming RPC over HTTP Connections").countersamples $rpc = $a + $b $rpc | Select-Object -Property Path, CookedValue
您也可以收集所有Get-Counter结果, 然后 Select CounterSample ,然后执行Select for Path , CookedValue 。