mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-15 22:48:17 +02:00
Update check-cpu.ps1
This commit is contained in:
parent
e82c36b07a
commit
11556dd0aa
@ -29,6 +29,20 @@ function GetCPUTemperatureInCelsius {
|
|||||||
return $Temp;
|
return $Temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function GetProcessorArchitecture {
|
||||||
|
if ("$env:PROCESSOR_ARCHITECTURE" -ne "") { return "$env:PROCESSOR_ARCHITECTURE" }
|
||||||
|
if ($IsLinux) {
|
||||||
|
$Name = $PSVersionTable.OS
|
||||||
|
if ($Name -like "*-generic *") {
|
||||||
|
if ([System.Environment]::Is64BitOperatingSystem) { return "x64" } else { return "x86" }
|
||||||
|
} elseif ($Name -like "*-raspi *") {
|
||||||
|
if ([System.Environment]::Is64BitOperatingSystem) { return "ARM64" } else { return "ARM32" }
|
||||||
|
} else {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Write-Progress "⏳ Querying CPU details..."
|
Write-Progress "⏳ Querying CPU details..."
|
||||||
$Status = "✅"
|
$Status = "✅"
|
||||||
@ -45,37 +59,24 @@ try {
|
|||||||
$Temp = "$($Celsius)°C"
|
$Temp = "$($Celsius)°C"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$Arch = GetProcessorArchitecture
|
||||||
if ($IsLinux) {
|
if ($IsLinux) {
|
||||||
$Name = $PSVersionTable.OS
|
|
||||||
if ($Name -like "*-generic *") {
|
|
||||||
if ([System.Environment]::Is64BitOperatingSystem) {
|
|
||||||
$Arch = "x64"
|
|
||||||
} else {
|
|
||||||
$Arch = "x86"
|
|
||||||
}
|
|
||||||
} elseif ($Name -like "*-raspi *") {
|
|
||||||
if ([System.Environment]::Is64BitOperatingSystem) {
|
|
||||||
$Arch = "ARM64"
|
|
||||||
} else {
|
|
||||||
$Arch = "ARM32"
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$Arch = ""
|
|
||||||
}
|
|
||||||
$CPUName = "$Arch CPU"
|
$CPUName = "$Arch CPU"
|
||||||
|
$Arch = ""
|
||||||
$DeviceID = ""
|
$DeviceID = ""
|
||||||
$Speed = ""
|
$Speed = ""
|
||||||
$Socket = ""
|
$Socket = ""
|
||||||
} else {
|
} else {
|
||||||
$Details = Get-WmiObject -Class Win32_Processor
|
$Details = Get-WmiObject -Class Win32_Processor
|
||||||
$CPUName = $Details.Name.trim()
|
$CPUName = $Details.Name.trim()
|
||||||
|
$Arch = "$Arch, "
|
||||||
$DeviceID = "$($Details.DeviceID), "
|
$DeviceID = "$($Details.DeviceID), "
|
||||||
$Speed = "$($Details.MaxClockSpeed)MHz, "
|
$Speed = "$($Details.MaxClockSpeed)MHz, "
|
||||||
$Socket = "$($Details.SocketDesignation) socket, "
|
$Socket = "$($Details.SocketDesignation) socket, "
|
||||||
}
|
}
|
||||||
$Cores = [System.Environment]::ProcessorCount
|
$Cores = [System.Environment]::ProcessorCount
|
||||||
Write-Progress -completed "done."
|
Write-Progress -completed "done."
|
||||||
Write-Host "$Status $CPUName ($Cores cores, $($DeviceID)$($Speed)$($Socket)$Temp)"
|
Write-Host "$Status $CPUName ($($Arch)$Cores cores, $($DeviceID)$($Speed)$($Socket)$Temp)"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user