PowerShell for Windows Admins

Nov 30 2019   5:58AM GMT


Richard Siddaway Richard Siddaway Profile: Richard Siddaway


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 :

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

\\w510w10\memory\cache faults/sec :

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

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

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.

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: