I want to develop a Powershell script to get CPU temperature.
Currently I'm using MSAcpi_ThermalZoneTemperature
class using Get-WMIObject
:
Get-WmiObject -Class MSAcpi_ThermalZoneTemperature -Namespace "root/wmi"
As a result of above command I'm getting 3 objects, only 1 of which is for the CPU:
__GENUS : 2
__CLASS : MSAcpi_ThermalZoneTemperature
__SUPERCLASS : MSAcpi
__DYNASTY : MSAcpi
__RELPATH : MSAcpi_ThermalZoneTemperature.InstanceName="ACPI\\ThermalZone\\TZ00_0"
__PROPERTY_COUNT : 12
__DERIVATION : {MSAcpi}
__SERVER : LAPTOP-T4Q10Q07
__NAMESPACE : root\wmi
__PATH : \\LAPTOP-T4Q10Q07\root\wmi:MSAcpi_ThermalZoneTemperature.InstanceName="ACPI\\ThermalZone\\TZ00_0"
Active : True
ActiveTripPoint : {3782, 3282, 3232, 0...}
ActiveTripPointCount : 3
CriticalTripPoint : 4832
CurrentTemperature : 0
InstanceName : ACPI\ThermalZone\TZ00_0
PassiveTripPoint : 0
Reserved : 0
SamplingPeriod : 0
ThermalConstant1 : 0
ThermalConstant2 : 0
ThermalStamp : 101
PSComputerName : LAPTOP-T4Q10Q07
__GENUS : 2
__CLASS : MSAcpi_ThermalZoneTemperature
__SUPERCLASS : MSAcpi
__DYNASTY : MSAcpi
__RELPATH : MSAcpi_ThermalZoneTemperature.InstanceName="ACPI\\ThermalZone\\TZ01_0"
__PROPERTY_COUNT : 12
__DERIVATION : {MSAcpi}
__SERVER : LAPTOP-T4Q10Q07
__NAMESPACE : root\wmi
__PATH : \\LAPTOP-T4Q10Q07\root\wmi:MSAcpi_ThermalZoneTemperature.InstanceName="ACPI\\ThermalZone\\TZ01_0"
Active : True
ActiveTripPoint : {0, 0, 0, 0...}
ActiveTripPointCount : 0
CriticalTripPoint : 4832
CurrentTemperature : 0
InstanceName : ACPI\ThermalZone\TZ01_0
PassiveTripPoint : 0
Reserved : 0
SamplingPeriod : 0
ThermalConstant1 : 0
ThermalConstant2 : 0
ThermalStamp : 101
PSComputerName : LAPTOP-T4Q10Q07
__GENUS : 2
__CLASS : MSAcpi_ThermalZoneTemperature
__SUPERCLASS : MSAcpi
__DYNASTY : MSAcpi
__RELPATH : MSAcpi_ThermalZoneTemperature.InstanceName="ACPI\\ThermalZone\\TZ02_0"
__PROPERTY_COUNT : 12
__DERIVATION : {MSAcpi}
__SERVER : LAPTOP-T4Q10Q07
__NAMESPACE : root\wmi
__PATH : \\LAPTOP-T4Q10Q07\root\wmi:MSAcpi_ThermalZoneTemperature.InstanceName="ACPI\\ThermalZone\\TZ02_0"
Active : True
ActiveTripPoint : {0, 0, 0, 0...}
ActiveTripPointCount : 0
CriticalTripPoint : 0
CurrentTemperature : 3010
InstanceName : ACPI\ThermalZone\TZ02_0
PassiveTripPoint : 0
Reserved : 0
SamplingPeriod : 0
ThermalConstant1 : 0
ThermalConstant2 : 0
ThermalStamp : 100
PSComputerName : LAPTOP-T4Q10Q07
Please suggest me how can I make script to return only object of cpu.