0

I am new to power shell scripting. I am trying performance monitor commands for local machine in windows power shell with run as administrator.

PS C:\windows\system32> Get-Counter "\\$env:COMPUTERNAME\Processor(_total)\% Processor Time" -SampleInterval 5 -MaxSamples 5 

But I am getting below error

Program 'Get-Counter' failed to run: No application is associated with the specified file for this operationAt line:1 char:1

Am unable to understand what is that error and why it is showing. I tried same command in another laptop, i am able to get response.

7
  • Get-Counter was first introduced in PS v3.0 (learn.microsoft.com/de-de/previous-versions/powershell/module/…) Make sure you have atleast version 3.0 installed. You can get your PS-Version with $PSVersionTable.PSVersion. Commented May 20, 2020 at 12:14
  • My power shell version is 5.1 Commented May 20, 2020 at 15:27
  • repair your windows counters. support.uptimesoftware.com/article.php?id=162 Commented May 21, 2020 at 3:39
  • can you get that counter to list as part of the available sets? something like this >>> (Get-Counter -ListSet 'processor' -ComputerName $env:COMPUTERNAME).Counter <<< Commented May 21, 2020 at 5:05
  • also, why do you have this tagged with powershell-core? your comment says you are running ps5.1 ... Commented May 21, 2020 at 5:09

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.