2017-06-23 12 views
2

Get-Counterを呼び出すときに、-ComputerNameパラメータを使用して、-Counterパラメータのパスを使用するのに違いはありますか?PowerShell Get-Counterコマンド、-ComputerName vs -Counter

Get-Counter -Counter "\Memory\Available MBytes" -ComputerName \\serv01 
Get-Counter -Counter "\\serv01\Memory\Available MBytes" 

どのような理由がありますか?

答えて

1

-ComputerNameパラメータを使用すると、1つのコマンドで複数のコンピュータのパフォーマンスカウンタからデータを取得できます。カウンタパスにservernameを指定すると、ループまたは複数の異なるコマンドを使用する必要があります。

例5:これは、通常、あなたが参照している逆らうものを知っている一般的なコマンドです

The first command saves the **Disk Reads/sec** counter path in the $DiskReads variable. 
PS C:\> $DiskReads = "\LogicalDisk(C:)\Disk Reads/sec" 

The second command uses a pipeline operator (|) to send the counter path in the $DiskReads variable to the **Get-Counter** cmdlet. The command uses the **MaxSamples** parameter to limit the output to 10 samples. 
PS C:\> $DiskReads | Get-Counter -Computer Server01, Server02 -MaxSamples 10 
0
Get-Counter -Counter "\Memory\Available MBytes" -ComputerName \\serv01 

複数のコンピュータから特定のカウンタデータを取得します。と知っているかもしれないまたは場所を知らないかもしれません。同じ名前の複数のカウンターがある場合これらのすべてのサーバー上のget-countersにコンピュータ名の複数のサーバーをパイプすることもできます。

Get-Counter -Counter "\\serv01\Memory\Available MBytes" 

これはカウンタが1つしかなく、特定の場所にあり、あなたが知っている特定のインスタンスです。

関連する問題