Getting CPU temperature using Powershell is a straightforward process. It is safer than using third-party apps for CPU temperature monitoring.
You would have noticed that most recommendations for CPU temperature monitoring on Windows 11 systems ask you to install third-party apps or applications on the computer to monitor CPU temperatures. Installing third-party apps is fraught with unintended consequences. Plus, in most corporate networks, you may have a hard time in getting these apps installed on Windows 11 systems.
So, we look at alternatives that can check CPU temperature on a Windows 11 computer through Powershell. With a single command line directive, we can get the temperature value of the CPU on the Powershell command prompt.
However, there are a few caveats that need to be aware of:
- This Powershell command directive’s output generates a CPU temperature value in Kelvin.
- Once you know the Kelvin temperature, you can convert it to Celsius by subtracting 273 from the Kelvin temperature
- An alternative is to use the Powershell script shared below.
Before starting the process of finding the CPU temperature on a Windows 11 computer, we need to start Powershell with administrative privileges on the computer.
To do so, you can type ‘pwsh’ in the search box of Windows 11 computer and then choose to ‘Run it as administrator’. The screenshot displays the exact command and the administrative option to check.
Get CPU temperature using WMI Object
We will make use of the WMI Object method to find the three values of temperature of the CPU on a Windows 11 computer.
For this exercise, we will use the in-build class of Win32_PerfFormattedData_Counters_ThermalZoneInformation.
The command directive below needs to be used to get the CPU temperature values on a Windows 11 computer:
Get-WMIObject -Query “SELECT * FROM Win32_PerfFormattedData_Counters_ThermalZoneInformation” -Namespace “root/CIMV2” | Select-object Temperature
The WMI-object command output is piped to the Select-object qualifier to get the temperature values in Kelvin.
The command and the output we get can be seen in the screenshot shared below:
- 283 Kelvin is equivalent to 10 degree Celsius
- 303 Kelvin is equivalent to 30 degree Celsius
- 301 Kelvin is equivalent to 28 degree Celsius
This is a quick and easy way to get an idea about the CPU temperature on a Windows 11 computer in Kelvin.
Similar to the WMI Object method, you can use the CIM Instance command below to find the temperature values in Kelvin. The command output is identical to what we have seen above.
Get-CIMInstance -Query “SELECT * FROM Win32_PerfFormattedData_Counters_ThermalZoneInformation” -Namespace “root/CIMV2” | Select-object Temperature
Get CPU temperature in Celsius using the Powershell function
You can use a Powershell script or function to get the temperature values of the CPU in Celsius directly. The function below will bring out the three temperature values of CPU temperature in Celsius.
function Get-Temperature {
$t = Get-WmiObject MSAcpi_ThermalZoneTemperature -Namespace “root/wmi”
$returntemp = @()
foreach ($temp in $t.CurrentTemperature) { $currentTempKelvin = $temp / 10 $currentTempCelsius = $currentTempKelvin – 273.15 $currentTempFahrenheit = (9/5) * $currentTempCelsius + 32 $returntemp += $currentTempCelsius.ToString() + ” C : ” + $currentTempFahrenheit.ToString() + ” F : ” + $currentTempKelvin + “K” } return $returntemp
}
Get-Temperature
You can use this function on the Powershell prompt. Or, you can save it as a PS file and execute it on the system.
I chose to put the function on the Powershell prompt directly and got the temperature values in Kelvin, Fahrenheit, and Celsius as displayed in the command output screenshot below.
Summary
Both these methods shared above will help you fetch the CPU temperature of a local or remote computer using Powershell. You can use these cmdlets on Windows 11, Windows 10, and Windows servers as well.
The good thing about getting temperature values through Powershell is that we do not need to install any third-party applications on your desktop or servers.
Rajesh Dhawan is a technology professional who loves to write about Cyber-security events and stories, Cloud computing and Microsoft technologies. He loves to break complex problems into manageable chunks of meaningful information.
To retrieve the CPU temperature using PowerShell, you can utilize the `Get-WmiObject` command to query the thermal zone data from the Win32_TemperatureProbe class. Here’s a simple code snippet to get you started:
Get-WmiObject -Namespace root\wmi -Class MSAcpi_ThermalZone | Select-Object -Property CurrentTemperature
This command will return the current temperature of your CPU in tenths of degrees Kelvin.
Understanding CPU Temperature
What is CPU Temperature?
CPU temperature refers to the heat generated by the processor during operation. Understanding this temperature is crucial because it directly impacts the performance of your computer. Most CPUs have an optimal operating temperature range. Operating outside this range can lead to performance throttling or even permanent damage.
Impact of High CPU Temperature
When the CPU operates at elevated temperatures, several adverse effects can occur.
- Performance Issues: High temperatures can cause the CPU to throttle its performance, meaning it runs slower to prevent damage.
- Risk of Overheating: Prolonged high temperatures may lead to hardware malfunctions or failure.
- System Instability: Crashes and unexpected behavior become more prevalent in systems where the CPU is consistently overheating.
Therefore, regular monitoring of CPU temperature is essential for maintaining system health and performance.
Mastering the PowerShell Enumerator: A Quick Guide
Setting Up PowerShell for CPU Monitoring
Prerequisites
Before you can monitor CPU temperature, ensure that PowerShell is installed on your system. Additionally, you may need administrative permissions to access certain system information.
Installing Necessary Tools
Using PowerShell Modules
PowerShell supports various modules that facilitate obtaining hardware information, including CPU temperature measurements. One such recommended module is OpenHardwareMonitor.
Example: Installing OpenHardwareMonitor Module
To install the module, run the following command in PowerShell:
Install-Module -Name OpenHardwareMonitor
This simple command will enable you to access the necessary functionalities for monitoring hardware metrics including CPU temperature.
Understanding the PowerShell Or Operator with Ease
Accessing CPU Temperature Data
Using WMI (Windows Management Instrumentation)
WMI Overview
WMI is a core component of Windows that allows scripts and management applications to interact with various system components. It can provide detailed information on hardware, including CPU temperature.
Retrieving CPU Temperature with WMI
To get the CPU temperature using WMI, you can execute the following command:
Get-WmiObject -Namespace root\wmi -Class MSAcpi_ThermalZone
This command retrieves temperature readings from the thermal zone. The output you get will show temperature values, typically in tenths of degrees Kelvin, which you can convert to Celsius for better understanding.
Using OpenHardwareMonitor
Accessing OpenHardwareMonitor Data
To use OpenHardwareMonitor for CPU temperature readings, first make sure to download and run OpenHardwareMonitor. This tool provides detailed insights and the necessary libraries to gather real-time data.
Example: Using OpenHardwareMonitor with PowerShell
To retrieve CPU temperature via OpenHardwareMonitor, use the following script:
# Load OpenHardwareMonitor assembly
Add-Type -Path "C:\Path\To\OpenHardwareMonitorLib.dll"
# Create object and retrieve temperatures
$monitor = New-Object OpenHardwareMonitor.Hardware.Computer
$monitor.Open()
$monitor.CPUEnabled = $true
$monitor.Activate()
# Display CPU temperatures
$monitor.Hardware | Where-Object { $_.HardwareType -eq 'Processor' } | ForEach-Object { $_.Sensors | Where-Object { $_.SensorType -eq 'Temperature' } }
This example loads the OpenHardwareMonitor library and activates the CPU data collection, providing clear temperature data that can be further processed or logged.
Mastering the PowerShell -In Operator: A Simple Guide
Setting Up Alerts for High Temperatures
Creating Alert Scripts
Setting up alerts is crucial, as it allows you to take action before overheating becomes a problem.
Example: Simple CPU Temperature Alert Script
Consider the following script to create an alert if CPU temperature breaches a specified threshold (e.g., 75°C):
$tempLimit = 75 # Set temperature threshold
$currentTemp = (Get-WmiObject -Namespace root\wmi -Class MSAcpi_ThermalZone).Temperature / 10 - 273.15
if ($currentTemp -gt $tempLimit) {
Write-Host "Alert: CPU temperature is above limit!" -ForegroundColor Red
}
This script fetches the current CPU temperature and displays a warning in red if it exceeds the set limit. You can adjust the `$tempLimit` variable to any temperature that you deem acceptable for your system.
PowerShell Script Template: Your Quick Start Guide
Regular Monitoring and Logging Procedures
Automating Temperature Checks
Regular monitoring can help you stay ahead of any potential issues related to CPU temperature. PowerShell scripts can be scheduled to run periodically.
Example: Create a Scheduled Task for CPU Monitoring
To automate the monitoring process, you can create a scheduled task with the following commands:
$action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "C:\Path\To\YourScript.ps1"
$trigger = New-ScheduledTaskTrigger -AtStartup
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "CPUTemperatureMonitor"
This command setup ensures your script runs at startup, continually keeping track of your CPU temperature every time your system boots up.
Logging CPU Temperature Data
Setting Up a Log File
Keeping a log of temperature readings can provide valuable insights over time. It allows you to observe trends and identify potential problems based on historical data.
Example: Logging Data to a CSV
You can log CPU temperatures to a CSV file for later analysis with the following script:
$currentTemp = (Get-WmiObject -Namespace root\wmi -Class MSAcpi_ThermalZone).Temperature / 10 - 273.15
$currentTime = Get-Date
$currentTemp | Out-File -FilePath "C:\Path\To\CPU_Temperature_Log.csv" -Append
This script appends the current temperature along with a timestamp to the specified CSV file, enabling easy tracking and analysis of your CPU’s temperature history.
Mastering the PowerShell Empire: Commands for Every Task
Troubleshooting Common Issues
Common Errors and Solutions
While accessing CPU temperature data with PowerShell, you may encounter several common issues. Some of these include:
- Access Denied: Ensure you have the necessary permissions to run scripts and access WMI.
- Module Not Found: Verify that the required module is installed correctly and that the path to OpenHardwareMonitor is accurate.
- No Data Returned: If no temperature data is returned, check whether OpenHardwareMonitor is running while executing the script.
Harness PowerShell Compress-Archive for Quick File Management
Conclusion
Monitoring CPU temperature with PowerShell not only helps you maintain optimal system performance but also protects your hardware. By regularly utilizing scripts to check CPU temperatures, setting up alerts, and logging data, you can ensure your system runs smoothly and efficiently.
Engaging with your system’s health through such proactive measures can contribute to an extended lifespan for your hardware and a more stable computing experience. Embrace the power of PowerShell to take control of your CPU’s thermal health.
Quick Guide to PowerShell SpeedTest Command
Additional Resources
Recommended Reading
Further your knowledge through various blogs, official documentation, and video tutorials dedicated to mastering PowerShell and hardware monitoring techniques.
Community Engagement
We encourage you to share your experiences, questions, and insights in the comments below. Your contributions could help fellow users enhance their understanding and application of PowerShell for monitoring CPU temperature.
In order to Monitor the Temperature of your CPU Cores it is best to make use of OpenHardwareMonitorLib
You can download it here.
This nice application has a .Net Library that you can use to access the Hardware Sensors Data
It also exposes the values to WMI when the GUI is started, but that is not so convenient for monitoring
SOLUTION :
# Needs admin privileges and the .NET OpenHardwareMonitorLib.dll #Requires -RunAsAdministrator CLS Add-Type -Path "C:\OpenHardwareMonitor\OpenHardwareMonitorLib.dll" $Comp = New-Object -TypeName OpenHardwareMonitor.Hardware.Computer $Comp.Open() $Comp.CPUEnabled = $true $Comp.RAMEnabled = $true $Comp.MainboardEnabled = $true $Comp.FanControllerEnabled = $true $Comp.GPUEnabled = $true $Comp.HDDEnabled = $true ForEach ($HW in $Comp.Hardware) { $hw.HardwareType.ToString() + ' - ' + $hw.name.ToString() If ( $hw.HardwareType -eq "CPU"){ ForEach ($Sensor in $HW.Sensors) { If ($Sensor.SensorType -eq "Temperature"){ $Sensor.Name + ' - Temp : ' + $Sensor.Value.ToString() + ' C - Min. : ' + $Sensor.Min.ToString() + ' C - Max : ' + $Sensor.Max.ToString() + ' C' } } } # $hw.Sensors $hw.SubHardware } $Comp.Close()
Apparently there has been a fork on this marvelous Library called LibreHardwareMonitor.
See here
Someone asked me to update the code to this more recent maintained Library using PS.
So here you go :
If you add an Email Notifications when it reaches the MAX values, you have a nice Monitoring System
Enjoy !
This entry was posted on Saturday, October 19th, 2019 at 10:03 pm and is filed under Powershell. You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Please note that this is quite old at this point and may or may not work for you. I leave it here for historical purposes | |
# and just in case it can help someone. I think I may have been using Windows 7 when I wrote this. | |
function Get-Temperature { | |
$t = Get-WmiObject MSAcpi_ThermalZoneTemperature -Namespace «root/wmi» | |
$currentTempKelvin = $t.CurrentTemperature / 10 | |
$currentTempCelsius = $currentTempKelvin — 273.15 | |
$currentTempFahrenheit = (9/5) * $currentTempCelsius + 32 | |
return $currentTempCelsius.ToString() + » C : » + $currentTempFahrenheit.ToString() + » F : » + $currentTempKelvin + «K» | |
} | |
# Save in your c:\users\yourName\Documents\WindowsPowerShell\modules\ directory | |
# in sub directory get-temperature as get-temperature.psm1 | |
# You **must** run as Administrator. | |
# It will only work if your system & BIOS support it. If it doesn’t work, I can’t help you. | |
# Just type get-temperature in PowerShell and it will spit back the temp in Celsius, Farenheit and Kelvin. | |
# More info on my blog: http://ammonsonline.com/is-it-hot-in-here-or-is-it-just-my-cpu/ |
Skip to content
We are in the middle of the May and we can say once again that the summer season has finally arrived. The days are hot and the nights are warm. In this climate, we have to take special care of our electronics and computing devices. We should clean the interiors of our desktop and notebook computer if possible. Cleaning the dust from the fans and other parts makes the ventilation faster and more effective.
You should also check the CPU temperature of your PC before and after the cleaning. You can also do the same after replacing the thermal paste for your CPU heatsink.
Here is how you can use PowerShell on a Windows PC to find the current CPU temperature easily:
- Launch PowerShell. This can be done in many ways but the easiest way is to through the Start menu. For this, we click on the Start, then type “PowerShell”. Then we can choose to “Run as administrator” for “Windows PowerShell”.
- In the PowerShell window enter the following:
wmic /namespace:\\root\wmi PATH MSAcpi_ThermalZoneTemperature get CurrentTemperature
- It will show the CPU temperature in Kelvin units multiplied by 10. So it must be divided by 10 and then we subtract 273.15 from it to get the actual CPU temperature. We can do the math’s in the PowerShell window itself.
In the above screenshot, PowerShell gave the CPU temperature as 3132. We divide it by 10 to get 313.2 which is CPU temperature in Kelvin. We subtract 273.15 from it to find 40.05 which is CPU temperature in Celsius.
You can verify this CPU temperature that we found through the PowerShell command by cross-checking with the temperatures shown by well know applications like HWInfo. You can download HWInfo from https://www.hwinfo.com/. It displays detailed information about your computer hardware along with the sensors data such as CPU temperature or hard disk drive temperature.
Similarly, if you want to find the CPU temperature in Fahrenheit units, then we multiply the temperature in Celsius by 9, divide by 5, and ten add 32 to it. All this can also be done in PowerShell.
Tagged with CPU
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.