header image

Get-Counter

Posted by: | November 30, 2019 Comments Off on Get-Counter |

The Get-Counter cmdlet returns in PowerShell v7 preview 6. Its only Get-Counter though the Import/Export-Counter cmdlets aren’t available. Get-Counter isn’t experimental feature so its available as soon as you install preview 6.

PS> Get-Command Get-Counter -Syntax

Get-Counter [[-Counter] <string[]>] [-SampleInterval <int>] [-MaxSamples <long>] [-Continuous] [-ComputerName <string[]>] [<CommonParameters>]

Get-Counter [-ListSet] <string[]> [-ComputerName <string[]>] [<CommonParameters>]

 

There’s a default set of counters available:

PS> Get-Counter

Timestamp CounterSamples
——— ————–
30/11/2019 11:44:52 \\w510w10\network interface(intel[r] 82577lm gigabit network connection)\bytes total/sec : 0

\\w510w10\network interface(11b_g_n wireless lan mini-pci express adapter ii)\bytes total/sec : 150.691579544147

\\w510w10\processor(_total)\% processor time :
0.9798448232225421

\\w510w10\memory\% committed bytes in use :
25.227649888309568

\\w510w10\memory\cache faults/sec :
18.961192128071477

\\w510w10\physicaldisk(_total)\% disk time :
0.30062706236372333

\\w510w10\physicaldisk(_total)\current disk queue length :
0

 

To see the available list of counter sets

PS> Get-Counter -ListSet * | select CounterSetName

 

To see the counters in a set

PS> Get-Counter -ListSet Processor | select -ExpandProperty Counter

 

To view a counter

PS> Get-Counter -Counter ‘\Processor(*)\% Processor Time’

 

The SampleInterval, MaxSamples and Continuous parameters can be used to control the number of samples and the time of recording.

under: PowerShell 7

Comments are closed.

Categories