Monday, December 7, 2020

Powershell - Get CPU temperature

As I encounter more and more slowness in our Dell laptop fleet, while Microsoft keeps pushing out updates that further tax older hardware...

(NOTE: Not all manufactures use BIOS that will work with the below)

One of the things I want to determine, is if the slowness a user is complaining about, can be resolved by just adding more RAM (remember when Windows 10 worked fine with 8 GB?), or if the computer is actually overheating - Such as, is the case when the heat sink paste is failing *

So I have been running the below script on the computer (have to run it as admin), to see if it is a heat issue, thus needing to replace that older equipment, or if I can just order in a 16 GM RAM kit.
$80 vs. $1800

I am in the US, so I work in Fahrenheit, but I did include the Kelvin to Centigrade conversion as well...


# It spits out as Kelvin with no decimal point, so you have to:
#      Divide it by 10, and then, convert it.
Invoke-Command -ComputerName RemotePC {

Function K2F {1.8 * (($args[0] / 10) - 273.15) + 32}
# Fahrenheit, because 'merikuh
Function K2C {(($args[0] / 10) - 273.15)}
# Swap it out below, if you need Centigrade
$Base = (Get-WmiObject MSAcpi_ThermalZoneTemperature -Namespace "root/wmi"); Write-Host ""
Write-Host " Current CPU temp: $(K2F ($Base.CurrentTemperature))° F" -ForegroundColor Cyan
Write-Host "    Crit CPU Temp: $(K2F ($Base.CriticalTripPoint))° F" -ForegroundColor Yellow
Write-Host " Overheat counter: $($Base.ActiveTripPointCount)" -ForegroundColor Green

}

 


Remember that aiming these at a remote PC, does require WinRM to be set up on the target.
I use Sysinternals - PsExec to get that in place. Here is an example:


$TestCommand
= $null
$TestCommand
= Test-WSMan -ComputerName $Target
If (!($TestCommand)){C:\SysInternals\PsExec.exe -s -nobanner \\$Target /accepteula cmd /c "c:\windows\system32\winrm.cmd quickconfig -quiet"}


* I learned along time ago, that the heat sink paste, is the easiest place for manufactures to insert their planned obsolescence factor.
Even if the laptop is lightly used, it will eventually begin to degrade, sooner if the laptop is heavily used...
I used to automatically re-paste a new PC's heat sink, any time I was buying a new laptop for my wife, or the kids, with a silver paste... But I digress
.

No comments:

Post a Comment