Powershell Day 24

Day 24 Performance Monitor

 Sql Performance:

 ❑ performance counters  sys.dm_os_performance_counters

❑ Top ten queries from sys.dm_exec_query_stats and sys.dm_exec_sql_text

❑ Processor: sys.dm_os_schedulers

❑Memory : sys.dm_os_memory_clerks

 Performance counters using WMIobject:

Formatted Data

❑get-wmiobject  Win32_PerfFormattedData_PerfDisk_PhysicalDisk

❑get-wmiobject  Win32_PerfFormattedData_PerfOS_Memory

❑get-wmiobject  Win32_PerfFormattedData_PerfOS_Processor

❑get-wmiobject  Win32_PerfFormattedData_PerfProc_Process

❑get-wmiobject  Win32_PerfFormattedData_Tcpip_NetworkInterface


ROW data

❑ Win32_PerfRawData_PerfDisk_PhysicalDisk

❑ Win32_PerfRawData_PerfOS_Memory

❑ Win32_PerfRawData_PerfOS_Processor

❑ Win32_PerfRawData_PerfProc_Process

❑ Win32_PerfRawData_Tcpip_NetworkInterface

 As we see the performance monitor can be using WMI now we can also use .net to get performance monitor information

 Using PerformanceCounter Object (.NET):


get-wmiobject Win32_PerfFormattedData_PerfProc_Process


$pc = new-object system.diagnostics.PerformanceCounter



$cat = new-object System.Diagnostics.PerformanceCounterCategory(“Process”)





 $pc.nextvalue() : is as good as Formatted Data


$pc.nextSample(): is as good as Row Data


 Version Powershell V2:

Powershell v2 has introduced new cmdlet for performance counter

get-counter -ListSet *

Get-counter Gets real-time performance counter data from local and remote computers.
Import-counter Exports PerformanceCounterSampleSet objects as performance counter log (.blg, .csv, .tsv) files.
Export-counter Imports performance counter log files and creates objects that represent each counter sample in the log.


This entry was posted in Powershell and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s