title: How to get CPU temperature in PowerShell 5.1 Version?
body: <p>I am trying to get CPU temperature by using Windows Powershell 5.1 by running the following code at the bottom but unfortunately my Powershell is not returning anything. I am wondering what code should I put in the Windows Powershell 5.1 version in order to get the CPU temperature. </p>
  
  <p>Code which I am using to get CPU temperature in Windows Powershell 5.1 version:</p>
  
  <pre><code>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
  </code></pre>