2015-03-31 32 views
0

我想在PowerShell中显示一秒钟内的上下文切换次数。我到目前为止一直试图在Get-Counter -Counter "System\Context Switches/sec"与“分”与“”和两个导致错误:Powershell计数上下文开关

Get-Counter : Internal performance counter API call failed. Error: c0bc4 

我知道的性能监视器的显示这种能力,我需要它显示为PowerShell中的文本。

回答

1

Geeze,我刚刚意识到这些命令是语言特定的。我的挪威体系只接受挪威的命令。这样就解决了我的问题!

挪威命令:Get-Counter -Counter "\System\Kontekstvekslinger/sek"

+0

你可以发布正确的命令,仅供将来参考。 – dimm 2015-03-31 10:35:57

+0

@dimm是的,完成了。 – Thomas 2015-03-31 10:39:54

2

您错过了领先的\。这将工作:

get-counter -Counter "\System\Context Switches/sec" 
+0

您好,我已经试过这藏汉,导致相同的错误代码。 *编辑*几乎相同的代码 - > c0bb9。 – Thomas 2015-03-31 10:03:13

+0

适合我。当我在你的问题中使用那个时,我得到相同的错误代码。也尝试过所有版本的PowerShell,它在每个版本都有效。你尝试以管理员身份运行吗? – arco444 2015-03-31 10:08:38

+0

是的,我也以管理员身份运行它,结果相同,很奇怪! – Thomas 2015-03-31 10:18:31

1

尝试将计算机名称放在路径中。

get-counter -Counter "\\<computer-name>\System\Context Switches/sec" 

虽然archo444答案应该工作。

+0

我测试过这个,结果相同:-( – Thomas 2015-03-31 10:23:31

0
$All = Get-Counter -ListSet * | ForEach-Object -Process { $PSItem.Paths; $PSItem.PathsWithInstances; } 

get-counter -Counter ($All | Select-String -Pattern "context") 

我得到同样的错误,像你我尝试这样,并得到结果精细