我正在监控每个 CAS 服务器的连接数,并希望连接每个服务器的输出,以便能够干净地显示它。
我尝试过“添加”结果,如 $rpc = $rpc + XXXCommandHereXXX,并按照下面的示例进行管道连接,但我无法“加入”命令。
$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
我是否试图做一些逻辑上不合理的事情?
答案1
不要Select-Object
对每个执行Get
。然后,您稍后就可以毫无问题地“添加”集合并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
s CounterSample
,然后执行Select
for Path
, CookedValue
。