- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get the windows performance counter using PowerShell?
To get the Windows Performance counter using the Powershell, we can use the Get-Counter cmdlet.
There are various performance counters available to measure the performance of the windows operating system. Get-Counter cmdlet is used to retrieve the performance of the local or the remote systems with the specific counter name.
When you just run a Get-Counter command, it shows the main basic counters like Nic, Processor, disks, etc on the local system. as shown below.
Example
PS C:\> Get-Counter Timestamp CounterSamples --------- -------------- 4/7/2021 7:41:42 PM \labmachine2k16
etwork interface(intel[r] 82574l gigabit network connection)\bytes total/sec : 0 \labmachine2k16
etwork interface(isatap.{5008ca11-6974-4ec6-b2d7-eef6f9632c45})\bytes total/sec : 0 \labmachine2k16\processor(_total)\% processor time : 65.3778486182899 \labmachine2k16\memory\% committed bytes in use : 36.8481297364571 \labmachine2k16\memory\cache faults/sec : 1168.99908419505 \labmachine2k16\physicaldisk(_total)\% disk time : 16.2392354345686 \labmachine2k16\physicaldisk(_total)\current disk queue length : 2
To get the counters on the remote system use -ComputerName parameter.
Example
Get-Counter -ComputerName TestMachine
To get the various available counter list, use -ListSet parameter.
Example
Get-Counter -ListSet *
Output
You can see the counterSetName with various counters in the Counter property. The machinename property shows the local or the remote machine. A dot (.) indicates the local machine name.
To find the specific counter related to Processor use the below command.
Example
Get-Counter -ListSet * | where{$_.CounterSetName -like "*Processor*"} | Select CounterSetName, Counter
Output
Similarly to get the disk-related counters use the below command,
Example
Get-Counter -ListSet * | where{$_.CounterSetName -like "*disk*"} | Select CounterSetName, Counter