Blog Post

Powershell One Liners: Get current cpu utilization on all your SQL Servers

,

# Assuming you have list of servers in servers.txt, each server name in its own line

$ComputerNames = get-content servers.txt


# Method 1 - Using the Get-Counter cmdlet
# Notice that here you can also easily add the interval and max sample sizes

Get-Counter -Counter "\Processor(_Total)\% Processor Time" -SampleInterval 10 -MaxSamples 5 -ComputerName $ComputerNames | Export-Counter -path PercentageProcessorTime.csv -fileformat csv -force

# Method 2 - Using WMI Object

Get-WmiObject -Query "Select * from Win32_PerfFormattedData_PerfOS_Processor where name = '_Total'" -ComputerName $ComputerNames | sort PercentProcessorTime -descending | ft -Property PSComputerName, name, PercentProcessorTime -autosize

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating