mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-22 12:41:24 +01:00
Update some check-*.ps1 scripts
This commit is contained in:
parent
b6baa94e3b
commit
888e0a5408
@ -22,17 +22,17 @@ try {
|
||||
$Temp = [math]::round($Temp / 100.0, 1)
|
||||
}
|
||||
if ($Temp -gt 80) {
|
||||
$Reply = "CPU is $($Temp)°C extremely hot!"
|
||||
$Reply = "⚠️ CPU has $($Temp)°C - too hot!"
|
||||
} elseif ($Temp -gt 50) {
|
||||
$Reply = "CPU is $($Temp)°C hot."
|
||||
$Reply = "✅ CPU has $($Temp)°C - hot."
|
||||
} elseif ($Temp -gt 0) {
|
||||
$Reply = "CPU is $($Temp)°C warm."
|
||||
$Reply = "✅ CPU has $($Temp)°C - warm."
|
||||
} elseif ($Temp -gt -20) {
|
||||
$Reply = "CPU is $($Temp)°C cold."
|
||||
$Reply = "✅ CPU has $($Temp)°C - cold."
|
||||
} else {
|
||||
$Reply = "CPU is $($Temp)°C extremely cold!"
|
||||
$Reply = "⚠️ CPU has $($Temp)°C - too cold!"
|
||||
}
|
||||
& "$PSScriptRoot/give-reply.ps1" $Reply
|
||||
"$Reply"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -12,11 +12,11 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
"⏳ Step 1/2 - Reading from Data/frequent-domains.csv..."
|
||||
Write-Progress "⏳ Step 1/2 - Reading from Data/frequent-domains.csv..."
|
||||
$Table = Import-CSV "$PSScriptRoot/../Data/frequent-domains.csv"
|
||||
$NumRows = $Table.Length
|
||||
|
||||
"⏳ Step 2/2 - Resolving $NumRows domains..."
|
||||
Write-Progress "⏳ Step 2/2 - Resolving $NumRows domains..."
|
||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
if ($IsLinux) {
|
||||
foreach($Row in $Table) { $null = dig $Row.Domain +short }
|
||||
@ -27,12 +27,15 @@ try {
|
||||
[float]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||
$Average = [math]::round($NumRows / $Elapsed, 1)
|
||||
|
||||
if ($Average -gt 200.0) { $Rating = "excellent" }
|
||||
elseif ($Average -gt 100.0) { $Rating = "quite good" }
|
||||
elseif ($Average -gt 10.0) { $Rating = "good" }
|
||||
else { $Rating = "poor" }
|
||||
|
||||
"✔️ $Average DNS domain lookups per second - $Rating"
|
||||
if ($Average -gt 200.0) {
|
||||
"✅ $Average DNS domain lookups per second - excellent"
|
||||
} elseif ($Average -gt 100.0) {
|
||||
"✅ $Average DNS domain lookups per second - quite good"
|
||||
} elseif ($Average -gt 10.0) {
|
||||
"✅ $Average DNS domain lookups per second - good"
|
||||
} else {
|
||||
"⚠️ $Average DNS domain lookups per second - poor"
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -11,6 +11,8 @@
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([int]$MinLevel = 50) # 50 GB minimum
|
||||
|
||||
try {
|
||||
$Drives = Get-PSDrive -PSProvider FileSystem
|
||||
foreach($Drive in $Drives) {
|
||||
@ -20,13 +22,13 @@ try {
|
||||
[int]$Total = ($Used + $Free)
|
||||
|
||||
if ($Total -eq "0") {
|
||||
$Reply = "Drive $($Drive.Name) is empty."
|
||||
$Reply = "✅ Drive $($Drive.Name) is empty."
|
||||
} elseif ($Free -lt $MinLevel) {
|
||||
$Reply = "Drive $($Drive.Name) has only $Free GB left to use! $Used of $Total GB is in use."
|
||||
$Reply = "⚠️ Drive $($Drive.Name) has only $Free GB left to use! $Used of $Total GB is in use."
|
||||
} else {
|
||||
$Reply = "Drive $($Drive.Name) has $($Free) GB left, $($Total) GB total."
|
||||
$Reply = "✅ Drive $($Drive.Name) has $($Free) GB left, $($Total) GB total."
|
||||
}
|
||||
"* $Reply"
|
||||
"$Reply"
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
|
@ -2,14 +2,9 @@
|
||||
.SYNOPSIS
|
||||
Checks the computer health
|
||||
.DESCRIPTION
|
||||
This PowerShell script checks the health of the local computer.
|
||||
This PowerShell script checks some health parameter of the local computer.
|
||||
.EXAMPLE
|
||||
PS> ./check-health
|
||||
✔️ 1213 GB left for swap space (67 of 1280 GB used)
|
||||
✔️ 172 GB left on drive C (61 of 233 GB used)
|
||||
✔️ 30.3 °C CPU temperature - good
|
||||
✔️ DNS resolution is 19.7 domains per second
|
||||
✔️ 29 ms ping average (13 ms min, 110 ms max, 10 hosts)
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -27,4 +22,5 @@
|
||||
if ($IsLinux) {
|
||||
& "$PSScriptRoot/check-smart-devices.ps1"
|
||||
}
|
||||
& "$PSScriptRoot/check-pending-reboot.ps1"
|
||||
exit 0 # success
|
||||
|
@ -21,7 +21,7 @@ try {
|
||||
$OSversion = $OS.Version
|
||||
$Reply = "$OSname for $OSarchitecture version $OSversion"
|
||||
}
|
||||
& "$PSScriptRoot/give-reply.ps1" "$Reply"
|
||||
"✅ $Reply"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -20,52 +20,44 @@ function Test-RegistryValue { param([parameter(Mandatory=$true)][ValidateNotNull
|
||||
}
|
||||
}
|
||||
|
||||
[bool]$PendingReboot = $false
|
||||
$Reason = ""
|
||||
|
||||
if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired") {
|
||||
"Yes, found registry key 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired'."
|
||||
$PendingReboot = $true
|
||||
$Reason +="found registry key 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired'."
|
||||
}
|
||||
if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\PostRebootReporting") {
|
||||
"Yes, found registry key 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\PostRebootReporting'."
|
||||
$PendingReboot = $true
|
||||
$Reason += "found registry key 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\PostRebootReporting'."
|
||||
}
|
||||
if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending") {
|
||||
"Yes, found registry key 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending'."
|
||||
$PendingReboot = $true
|
||||
$Reason += "found registry key 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending'."
|
||||
}
|
||||
if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\ServerManager\CurrentRebootAttempts") {
|
||||
"Yes, found registry key 'HKLM:\SOFTWARE\Microsoft\ServerManager\CurrentRebootAttempts'."
|
||||
$PendingReboot = $true
|
||||
$Reason += "found registry key 'HKLM:\SOFTWARE\Microsoft\ServerManager\CurrentRebootAttempts'."
|
||||
}
|
||||
if (Test-RegistryValue -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing" -Value "RebootInProgress") {
|
||||
"Yes, registry key 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing' contains 'RebootInProgress'."
|
||||
$PendingReboot = $true
|
||||
$Reason += "registry key 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing' contains 'RebootInProgress'."
|
||||
}
|
||||
if (Test-RegistryValue -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing" -Value "PackagesPending") {
|
||||
"Yes, registry key 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing' contains 'PackagesPending'."
|
||||
$PendingReboot = $true
|
||||
$Reason += "registry key 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing' contains 'PackagesPending'."
|
||||
}
|
||||
if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager" -Value "PendingFileRenameOperations") {
|
||||
"Yes, registry key 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' contains 'PendingFileRenameOperations'."
|
||||
$PendingReboot = $true
|
||||
$Reason += "registry key 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' contains 'PendingFileRenameOperations'."
|
||||
}
|
||||
if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager" -Value "PendingFileRenameOperations2") {
|
||||
"Yes, registry key 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' contains 'PendingFileRenameOperations2'."
|
||||
$PendingReboot = $true
|
||||
$Reason += "registry key 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' contains 'PendingFileRenameOperations2'."
|
||||
}
|
||||
if (Test-RegistryValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" -Value "DVDRebootSignal") {
|
||||
"Yes, registry key 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce' contains 'DVDRebootSignal'."
|
||||
$PendingReboot = $true
|
||||
$Reason += "registry key 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce' contains 'DVDRebootSignal'."
|
||||
}
|
||||
if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon" -Value "JoinDomain") {
|
||||
"Yes, registry key 'HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon' contains 'JoinDomain'."
|
||||
$PendingReboot = $true
|
||||
$Reason += "registry key 'HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon' contains 'JoinDomain'."
|
||||
}
|
||||
if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon" -Value "AvoidSpnSet") {
|
||||
"Yes, registry key 'HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon' contains 'AvoidSpnSet'."
|
||||
$PendingReboot = $true
|
||||
$Reason += "registry key 'HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon' contains 'AvoidSpnSet'."
|
||||
}
|
||||
if ($Reason -eq "") {
|
||||
"✅ No pending reboot."
|
||||
} else {
|
||||
"⚠️pending reboot ($Reason)."
|
||||
}
|
||||
|
||||
if ($PendingReboot -eq $false) { "No pending reboot" }
|
||||
exit 0 # success
|
@ -8,7 +8,7 @@
|
||||
Specifies the hosts to check (separated by comma)
|
||||
.EXAMPLE
|
||||
PS> ./check-ping
|
||||
✔️ Average ping is 36ms average (13ms min, 109ms max)
|
||||
✅ Average ping is 36ms (13ms min, 109ms max)
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -36,8 +36,7 @@ try {
|
||||
$Avg += $Latency
|
||||
}
|
||||
$Avg = $Avg / $Pings.count
|
||||
|
||||
& "$PSScriptRoot/give-reply.ps1" "$($Avg)ms average ping time ($($Min)ms min, $($Max)ms max)"
|
||||
"✅ Average ping is $($Avg)ms ($($Min)ms min, $($Max)ms max)."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -7,7 +7,7 @@
|
||||
Specifies the minimum level (50 GB by default)
|
||||
.EXAMPLE
|
||||
PS> ./check-swap-space
|
||||
✔️ 1213 GB left for swap space (67 of 1280 GB used)
|
||||
Swap space has 1826 GB left (1856 GB total)
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -36,9 +36,9 @@ try {
|
||||
} elseif ($Free -lt $MinLevel) {
|
||||
$Reply = "Swap space has only $Free GB left to use! ($Used of $Total GB used, minimum is $MinLevel GB)"
|
||||
} else {
|
||||
$Reply = "Swap space has $Free GB left ($Total GB total)"
|
||||
$Reply = "✅ Swap space has $Free GB left, $Total GB total."
|
||||
}
|
||||
& "$PSScriptRoot/give-reply.ps1" "$Reply"
|
||||
"$Reply"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -19,12 +19,11 @@ try {
|
||||
$TimeNow = Get-Date
|
||||
$Uptime = New-TimeSpan -Start $BootTime.TimeCreated.Date -End $TimeNow
|
||||
}
|
||||
|
||||
$Days = $Uptime.Days
|
||||
$Hours = $Uptime.Hours
|
||||
$Minutes = $Uptime.Minutes
|
||||
|
||||
$Reply = "I'm up for "
|
||||
$Reply = "Up for "
|
||||
if ($Days -eq "1") {
|
||||
$Reply += "1 day, "
|
||||
} elseif ($Days -ne "0") {
|
||||
@ -40,8 +39,7 @@ try {
|
||||
} elseif ($Minutes -ne "0") {
|
||||
$Reply += "and $Minutes minutes"
|
||||
}
|
||||
$Reply += "."
|
||||
& "$PSScriptRoot/give-reply.ps1" "$Reply"
|
||||
"✅ $Reply."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Loading…
Reference in New Issue
Block a user