CPU Utilisation of SharePoint Farm

By | August 24, 2012

A useful Powershell tip of the day today.

Get the CPU utilisation of all servers in the farm (specific to my demo environment, clearly -like or -match on your server prefix).

# script block starts here
$farmservers = Get-SPServer | ?{$_.address -like “DEMSP*”}
$totalutil = 0
foreach ($farmserver in $farmservers) {
$cpuobjects = Get-WmiObject -ComputerName $farmserver.address win32_processor
foreach ($cpu in $cpuobjects) {
$totalutil = $totalutil + $cpu.LoadPercentage
}
$aveutil = $totalutil / $cpuobjects.Count
write-host “CPU util on $($farmserver.address) is $aveutil”
$totalutil = 0
# script block ends here

Hopefully you’ll find it useful.

More to follow…

Leave a Reply

Your email address will not be published. Required fields are marked *