Select Page

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…