Updated some scripts

This commit is contained in:
Markus Fleschutz 2024-05-26 12:31:05 +02:00
parent c08c36b456
commit 1640c9349d
3 changed files with 6 additions and 6 deletions

View File

@ -73,8 +73,8 @@ try {
$temp = "$($celsius)°C" $temp = "$($celsius)°C"
} }
Write-Progress -completed "Done."
Write-Host "$status $cpuName ($($arch)$cores cores, $($deviceID)$($speed)$($socket)$temp)" Write-Host "$status $cpuName ($($arch)$cores cores, $($deviceID)$($speed)$($socket)$temp)"
Write-Progress -completed "Done."
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -50,7 +50,7 @@ try {
$powerScheme = $powerScheme -Replace "\)$","" $powerScheme = $powerScheme -Replace "\)$",""
$reply += " · power scheme '$powerScheme'" $reply += " · power scheme '$powerScheme'"
} }
Write-Output $reply Write-Host $reply
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -29,18 +29,18 @@ function Bytes2String([int64]$bytes) {
} }
try { try {
Write-Progress "(1/3) Searching for smartmontools..." #Write-Progress "(1/3) Searching for smartmontools..."
$result = (smartctl --version) $result = (smartctl --version)
if ($lastExitCode -ne "0") { throw "Can't execute 'smartctl' - make sure smartmontools are installed" } if ($lastExitCode -ne "0") { throw "Can't execute 'smartctl' - make sure smartmontools are installed" }
Write-Progress "(2/3) Scanning S.M.A.R.T devices..." #Write-Progress "(2/3) Scanning S.M.A.R.T devices..."
if ($IsLinux) { if ($IsLinux) {
$devices = $(sudo smartctl --scan-open) $devices = $(sudo smartctl --scan-open)
} else { } else {
$devices = $(smartctl --scan-open) $devices = $(smartctl --scan-open)
} }
Write-Progress "(3/3) Querying S.M.A.R.T devices..." #Write-Progress "Querying S.M.A.R.T devices..."
foreach($device in $devices) { foreach($device in $devices) {
$array = $device.split(" ") $array = $device.split(" ")
$dev = $array[0] $dev = $array[0]
@ -89,7 +89,7 @@ try {
$firmwareVersion = $details.firmware_version $firmwareVersion = $details.firmware_version
Write-Host "$status $capacity$modelName via $protocol ($temp, $hours, $powerOn, $selftest, v$firmwareVersion)" Write-Host "$status $capacity$modelName via $protocol ($temp, $hours, $powerOn, $selftest, v$firmwareVersion)"
} }
Write-Progress -completed " " #Write-Progress -completed "Done."
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"