PowerShell's Get-Counter is an alternative technique to employing
Perfmon. Normally it's easy to be enthusiastic about PowerShell, but
in the case of Get-Counter, I would not attempt to create scripts until I
had a working knowledge of
Performance Monitoring.
Success or failure of Get-Counter missions depends on having clear
objectives. You need a working knowledge of Performance Monitoring
because you need to make sense of strings such as:
Once you beg, borrow or copy the correct Performance counter, then
preceding with Get-Counter is the easy part. However, all is not plain
sailing, you need to be able to interpret the data, and probably save to
file (Out-File).
Note 1a: You really do need the full parameter name -ListSet.
PowerShell has lots of cmdlets that use just -list, but Get-Counter is NOT
one of them.
Note 1b: Pure -ListSet * returns so many
CounterSetNames that is why I filtered the command to display just the memory counters.
Also note that -ListSet on its own does not work, furthermore you need
that space between -ListSet and the * wildcard.
Note 2a: You probably need to adjust
C:\logs\processor.ps1 to a valid path on your computer.
Guy
Recommends: WMI Monitor and It's Free!
Windows Management Instrumentation (WMI) is one of the hidden
treasures of Microsoft operating systems. Fortunately, SolarWinds
have created a
Free WMI Monitor so that you can discover these gems of performance
information, and thus improve your PowerShell scripts. Take the guess work out of which WMI counters to use when scripting the
operating system, Active Directory or Exchange Server.
Note: While this is a real example, it's meant to give you a template
which you can alter to suit your project, for example, you not only change
'Virtual Bytes' for 'Working Set', but you could choose a completely
different counter, for example 'Memory' or 'Processor'. To see what
I mean go back to -listSet in
Example 1.
Note 4a: The above little script reveals over 50
disk properties. The main features of these counters are Read or
Write, Average or Percentage.
Guy Recommends: A Free Trial of the Network Performance Monitor
(NPM)
SolarWinds'
Orion performance monitor
will help you discover what's happening on your network. This
utility will also guide you through troubleshooting; the dashboard will
indicate whether the root cause is a broken link, faulty equipment or
resource overload.
Perhaps the NPM's best feature is the way it suggests solutions to network
problems. Its
second best feature is the ability to monitor the health of individual VMware
virtual machines. If you are interested in troubleshooting, and creating network maps, then I recommend that you take advantage of SolarWinds' offer.
# PowerShell Counter Cmdlet Research Clear-Host
Get-Command -noun Counter
The above script reveals the sister commands Import-Counter and
Export-Counter. While it's moderately easy to see what these cmdlets do,
I have never seen anyone use them in real-life.
Summary of PowerShell Get-Counter
To be frank, as someone who is a minor expert in both PowerShell and
performance monitoring I would encourage to seek other methods of achieving
your goals before turning to Get-Counter.
See More Windows PowerShell Examples of Real-life Tasks
Please email me if you have a better example script. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.
Windows Management Instrumentation (WMI) is one of the hidden
treasures of Microsoft operating systems.
Fortunately, SolarWinds
have created the
Free WMI Monitor so that you can actually see and understand these gems of
performance information. Take the guess work out of which
WMI counters to use for applications like Microsoft Active Directory,
SQL or Exchange Server.