CmdID

CmdID / PowerShell / Cmdlets / Get

Get-Counter

Gets performance counter data from local and remote computers. PowerShell reference

From the PowerShell reference 6 parameters

Opens CmdID with your command, read as PowerShell. It is read in your browser and sent nowhere.

What it does

from the PowerShell reference, CC BY 4.0

Gets performance counter data from local and remote computers. The Get-Counter cmdlet gets performance counter data directly from the performance monitoring instrumentation in the Windows family of operating systems. Get-Counter gets performance data from a local computer or remote computers. You can use the Get-Counter parameters to specify one or more computers, list the performance counter sets and the instances they contain, set the sample intervals, and specify the maximum number of samples. Without parameters, Get-Counter gets performance counter data for a set of system counters. Many counter sets are protected by access control lists (ACL). To see all counter sets, open PowerShell with the Run as administrator option. NOTE: Performance counter names are localized. The examples shown here use the English names of the performance objects, counters, and instances. The names will be different on a system that uses another language. Use the Get-Counter -ListSet command to see the localized names.

Get-Counter [[-Counter] <String[]>] [-SampleInterval <Int32>] [-MaxSamples <Int64>] [-Continuous] [-ComputerName <String[]>] [<CommonParameters>]
Get-Counter [-ListSet] <String[]> [-ComputerName <String[]>] [<CommonParameters>]

Get the counter set list

Get-Counter -ListSet *Identify

Specify the SampleInterval and MaxSamples

Get-Counter -Counter "\Processor(_Total)\% Processor Time" -SampleInterval 2 -MaxSamples 3Identify

Get continuous samples of a counter

Get-Counter -Counter "\Processor(_Total)\% Processor Time" -ContinuousIdentify

Alphabetical list of counter sets

Get-Counter -ListSet * | Sort-Object -Property CounterSetName | Format-Table CounterSetName, CounterSetType -AutoSizeIdentify

Run a background job to get counter data

Start-Job -ScriptBlock { Get-Counter -Counter "\LogicalDisk(_Total)\% Free Space" -MaxSamples 1000 }Identify

Get counter data from multiple computers

$DiskReads = "\LogicalDisk(C:)\Disk Reads/sec" $DiskReads | Get-Counter -ComputerName Server01, Server02 -MaxSamples 10Identify

Get a counter's instance values from multiple random computers

$Servers = Get-Random (Get-Content -Path C:\Servers.txt) -Count 50 $Counter = "\Processor(*)\% Processor Time" Get-Counter -Counter $Counter -ComputerName $ServersIdentify

Use the Path property to get formatted path names

(Get-Counter -ListSet Memory).Paths | Where-Object { $_ -like "Cache" }Identify

Use the PathsWithInstances property to get formatted path names

(Get-Counter -ListSet PhysicalDisk).PathsWithInstancesIdentify

Get a single value for each counter in a counter set

$MemCounters = (Get-Counter -ListSet Memory).Paths Get-Counter -Counter $MemCountersIdentify

Its page in the reference: Get-Counter.

Parameters

6 in the PowerShell reference
-ComputerNameSpecifies one computer name or a comma-separated array of remote computer names. Use the NetBIOS name, an IP address, or the computer's fully qualified domain name. To get performance counter data from the local computer, exclude the ComputerName parameter. For output such as a ListSet that contains the MachineName column, a dot (.) indicates the local computer. Get-Counter doesn't rely on PowerShell remoting. You can use the ComputerName parameter even if your computer isn't configured to run remote commands.
-ContinuousWhen Continuous is specified, Get-Counter gets samples until you press <kbd>CTRL</kbd>+<kbd>C</kbd>. Samples are obtained every second for each specified performance counter. Use the SampleInterval parameter to increase the interval between continuous samples.
-CounterSpecifies the path to one or more counter paths. Paths are input as a comma-separated array, a variable, or values from a text file. You can send counter path strings down the pipeline to Get-Counter. Counter paths use the following syntax: \\ComputerName\CounterSet(Instance)\CounterName \CounterSet(Instance)\CounterName For example: \\Server01\Processor(*)\% User Time \Processor(*)\% User Time The \\ComputerName is optional in a performance counter path. If the counter path doesn't include the computer name, Get-Counter uses the local computer. An asterisk (*) in the instance is a wildcard character to get all instances of the counter.
-ListSetLists the performance counter sets on the computers. Use an asterisk (*) to specify all counter sets. Enter one name or a comma-separated string of counter set names. You can send counter set names down the pipeline. To get a counter sets formatted counter paths, use the ListSet parameter. The Paths and PathsWithInstances properties of each counter set contain the individual counter paths formatted as a string. You can save the counter path strings in a variable or use the pipeline to send the string to another Get-Counter command. For example to send each Processor counter path to Get-Counter: Get-Counter -ListSet Processor | Get-Counter
-MaxSamplesSpecifies the number of samples to get from each specified performance counter. To get a constant stream of samples, use the Continuous parameter. If the MaxSamples parameter isn't specified, Get-Counter only gets one sample for each specified counter. To collect a large data set, run Get-Counter as a PowerShell background job. For more information, see about_Jobs.
-SampleIntervalSpecifies the number of seconds between samples for each specified performance counter. If the SampleInterval parameter isn't specified, Get-Counter uses a one-second interval.