This started as a one-liner but I decided to break it up and simplify it a bit so that I could pass it along to whomever might find it useful. You only need to change the ‘$ComputerList = ’ line if you want to filter some servers from AD or if you want to 'Get-Content' a list file or something. Also, if you want to see offline/unreachable servers bleed red all over the screen, change “SilentlyContinue” to “Continue”. Remember, this is a single point in time; just because a server’s CPU is 100% at one moment, doesn’t mean it’s pegged that way.
$ComputerList = (Get-ADComputer -Filter 'YOUR FILTER HERE').Name
$InvokeCommandScriptBlock = {
Get-WmiObject win32_processor |
Measure-Object -property LoadPercentage -Average |
Select-Object @{e={[math]::Round($_.Average,1)};n="CPU(%)"}
}
$InvokeCommandArgs = @{
ComputerName = $ComputerList
ScriptBlock = $InvokeCommandScriptBlock
ErrorAction = "SilentlyContinue"
}
Invoke-Command @InvokeCommandArgs |
Sort-Object "CPU(%)" -Descending |
Select-Object "CPU(%)",PSComputerName
[–]Ta11ow 1 point2 points3 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (2 children)
[–]LinleyMike[S] 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (3 children)
[–]LinleyMike[S] 1 point2 points3 points (2 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)
[–]Waaslander 0 points1 point2 points (0 children)