mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-26 01:43:37 +01:00
Updated some check-*.ps1 scripts
This commit is contained in:
parent
f71ce2419d
commit
0cef271a29
@ -15,7 +15,7 @@ try {
|
||||
if ($IsLinux) {
|
||||
# TODO
|
||||
} else {
|
||||
Write-Progress "⏳ (1/2) Querying installed apps (for current user only)..."
|
||||
Write-Progress "⏳ Querying installed apps..."
|
||||
$Apps = Get-AppxPackage
|
||||
[int]$NumInstalled = $Apps.Count
|
||||
[int]$NumIssues = 0
|
||||
@ -23,12 +23,12 @@ try {
|
||||
if ($App.Status -ne "Ok") { $NumIssues++ }
|
||||
}
|
||||
|
||||
Write-Progress "⏳ (2/2) Querying available updates..."
|
||||
Write-Progress "⏳ Querying available updates..."
|
||||
$NumUpdates = (winget upgrade --include-unknown).Count - 5
|
||||
|
||||
Write-Progress -Completed " "
|
||||
[int]$NumErrors = (Get-AppxLastError)
|
||||
"✅ $NumInstalled apps installed, $NumIssues non-ok, $NumErrors errors, $NumUpdates updates available"
|
||||
Write-Host "✅ $NumInstalled apps installed, $NumIssues non-ok, $NumErrors errors, $NumUpdates updates available"
|
||||
Write-Progress -Completed " "
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
|
@ -30,7 +30,7 @@ try {
|
||||
if ($Remaining -lt 30) { $Status = "⚠️" }
|
||||
$Battery = "$Percent% battery life, $Remaining min. left"
|
||||
}
|
||||
"$Status $Power, $Battery"
|
||||
Write-Host "$Status $Power, $Battery"
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
|
@ -30,7 +30,7 @@ function GetCPUTemperatureInCelsius {
|
||||
}
|
||||
|
||||
try {
|
||||
Write-Progress "Querying CPU details ..."
|
||||
Write-Progress "⏳ Querying CPU details ..."
|
||||
$Status = "✅"
|
||||
$Celsius = GetCPUTemperatureInCelsius
|
||||
if ($Celsius -eq 99999.9) {
|
||||
@ -68,6 +68,7 @@ try {
|
||||
}
|
||||
$Cores = [System.Environment]::ProcessorCount
|
||||
Write-Host "$Status $CPUName ($Cores cores, $($DeviceID)$($Speed)$($Socket)$Temp)"
|
||||
Write-Progress -Completed " "
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -12,11 +12,11 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
Write-Progress "⏳ (1/2) Loading Data/popular-domains.csv..."
|
||||
Write-Progress "⏳ Loading Data/popular-domains.csv..."
|
||||
$Table = Import-CSV "$PSScriptRoot/../Data/popular-domains.csv"
|
||||
$NumRows = $Table.Length
|
||||
|
||||
Write-Progress "⏳ (2/2) Resolving $NumRows domains..."
|
||||
Write-Progress "⏳ Resolving $NumRows domains..."
|
||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
if ($IsLinux) {
|
||||
foreach($Row in $Table){$nop=dig $Row.Domain +short}
|
||||
@ -25,15 +25,15 @@ try {
|
||||
}
|
||||
[float]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||
|
||||
Write-Progress -Completed " "
|
||||
$Average = [math]::round($NumRows / $Elapsed, 1)
|
||||
if ($Average -gt 100.0) {
|
||||
"✅ DNS resolves excellent $Average domains per second"
|
||||
Write-Host "✅ DNS resolves excellent $Average domains per second"
|
||||
} elseif ($Average -gt 10.0) {
|
||||
"✅ DNS resolves $Average domains per second"
|
||||
Write-Host "✅ DNS resolves $Average domains per second"
|
||||
} else {
|
||||
"⚠️ DNS resolves only $Average domains per second!"
|
||||
Write-Host "⚠️ DNS resolves only $Average domains per second!"
|
||||
}
|
||||
Write-Progress -Completed " "
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -7,6 +7,7 @@
|
||||
Specifies the minimum warning level (10 GB by default)
|
||||
.EXAMPLE
|
||||
PS> ./check-drives
|
||||
✅ Drive C uses 87GB of 249GB
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
|
@ -38,6 +38,7 @@ try {
|
||||
$Status = $Details.Status
|
||||
Write-Host "✅ $Model GPU ($(Bytes2String $RAMSize) RAM, $($ResWidth)x$($ResHeight) pixels, $BitsPerPixel bit, $RefreshRate Hz, driver $DriverVersion, status $Status)"
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
|
@ -15,7 +15,7 @@ try {
|
||||
if ($IsLinux) {
|
||||
$Name = $PSVersionTable.OS
|
||||
if ([System.Environment]::Is64BitOperatingSystem) { $Bits = "64-bit" } else { $Bits = "32-bit" }
|
||||
"✅ $Name ($Bits)"
|
||||
Write-Host "✅ $Name ($Bits)"
|
||||
} else {
|
||||
$OS = Get-WmiObject -class Win32_OperatingSystem
|
||||
$Name = $OS.Caption -Replace "Microsoft Windows","Windows"
|
||||
@ -29,7 +29,7 @@ try {
|
||||
$InstallDate = $OSDetails.InstallDate
|
||||
|
||||
$ProductKey = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" -Name BackupProductKeyDefault).BackupProductKeyDefault
|
||||
"✅ $Name ($Arch, v$Version, S/N $Serial, P/K $ProductKey) since $($InstallDate.ToShortDateString())"
|
||||
Write-Host "✅ $Name ($Arch, v$Version, S/N $Serial, P/K $ProductKey) since $($InstallDate.ToShortDateString())"
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
|
@ -20,8 +20,8 @@ function Test-RegistryValue { param([parameter(Mandatory=$true)][ValidateNotNull
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$Reason = ""
|
||||
|
||||
if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired") {
|
||||
$Reason += ", found registry entry '...\WindowsUpdate\Auto Update\RebootRequired'"
|
||||
}
|
||||
@ -56,8 +56,12 @@ if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon"
|
||||
$Reason += ", found registry entry '...\CurrentControlSet\Services\Netlogon' with 'AvoidSpnSet'"
|
||||
}
|
||||
if ($Reason -ne "") {
|
||||
"⚠️ Pending reboot ($($Reason.substring(2)))"
|
||||
Write-Host "⚠️ Pending reboot ($($Reason.substring(2)))"
|
||||
} else {
|
||||
"✅ No pending reboot"
|
||||
Write-Host "✅ No pending reboot"
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -17,11 +17,11 @@
|
||||
param([string]$hosts = "amazon.com,bing.com,cnn.com,dropbox.com,facebook.com,google.com,live.com,twitter.com,youtube.com")
|
||||
|
||||
try {
|
||||
Write-Progress "⏳ (1/2) Pinging $hosts..."
|
||||
Write-Progress "⏳ Pinging $hosts..."
|
||||
$HostsArray = $hosts.Split(",")
|
||||
$Pings = Test-Connection -count 1 -computerName $HostsArray
|
||||
|
||||
Write-Progress "⏳ (2/2) Calculating results..."
|
||||
Write-Progress "⏳ Calculating results..."
|
||||
[int]$Min = 9999999
|
||||
[int]$Max = [int]$Avg = 0
|
||||
foreach($Ping in $Pings) {
|
||||
@ -32,8 +32,8 @@ try {
|
||||
}
|
||||
$Avg /= $Pings.count
|
||||
|
||||
Write-Host "✅ Ping is $($Avg)ms average, $($Min)ms min, $($Max)ms max"
|
||||
Write-Progress -Completed " "
|
||||
"✅ Ping is $($Avg)ms average, $($Min)ms min, $($Max)ms max"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -5,7 +5,7 @@
|
||||
This PowerShell script queries S.M.A.R.T. HDD/SSD device details and prints it.
|
||||
.EXAMPLE
|
||||
PS> ./check-smart-devices
|
||||
✅ 1TB Samsung SSD 970 EVO (via NVMe, 2388 hours, 289x on, v2B2QEXE7, 37°C, selftest passed)
|
||||
✅ 1TB Samsung SSD 970 EVO via NVMe (2388 hours, 289x on, v2B2QEXE7, 37°C, selftest passed)
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -29,18 +29,18 @@ function Bytes2String { param([int64]$Bytes)
|
||||
}
|
||||
|
||||
try {
|
||||
Write-Progress "⏳ Step 1/3 - Searching for smartctl executable..."
|
||||
Write-Progress "⏳ Searching for smartctl executable..."
|
||||
$Result = (smartctl --version)
|
||||
if ($lastExitCode -ne "0") { throw "Can't execute 'smartctl' - make sure smartmontools are installed" }
|
||||
|
||||
Write-Progress "⏳ Step 2/3 - Scanning S.M.A.R.T devices..."
|
||||
Write-Progress "⏳ Scanning S.M.A.R.T devices..."
|
||||
if ($IsLinux) {
|
||||
$Devices = $(sudo smartctl --scan-open)
|
||||
} else {
|
||||
$Devices = $(smartctl --scan-open)
|
||||
}
|
||||
foreach($Device in $Devices) {
|
||||
Write-Progress "⏳ Step 3/3 - Querying S.M.A.R.T devices..."
|
||||
Write-Progress "⏳ Querying S.M.A.R.T devices..."
|
||||
$Array = $Device.split(" ")
|
||||
$Device = $Array[0]
|
||||
if ("$Device" -eq "#") {
|
||||
@ -65,8 +65,9 @@ try {
|
||||
$PowerOn = $Details.power_cycle_count
|
||||
$Hours = $Details.power_on_time.hours
|
||||
if ($Details.smart_status.passed) { $Status = "passed" } else { $Status = "FAILED" }
|
||||
"✅ $($Capacity)$ModelName (via $Protocol, $Hours hours, $($PowerOn)x on, v$($Firmware), $($Temp)°C, selftest $Status)"
|
||||
Write-Host "✅ $($Capacity)$ModelName via $Protocol ($Hours hours, $($PowerOn)x on, v$($Firmware), $($Temp)°C, selftest $Status)"
|
||||
}
|
||||
Write-Progress -Completed " "
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -44,17 +44,17 @@ try {
|
||||
}
|
||||
}
|
||||
if ($Total -eq 0) {
|
||||
"⚠️ No swap space configured!"
|
||||
Write-Host "⚠️ No swap space configured!"
|
||||
} elseif ($Free -eq 0) {
|
||||
"⚠️ Swap space of $(MB2String $Total) is full!"
|
||||
Write-Host "⚠️ Swap space of $(MB2String $Total) is full!"
|
||||
} elseif ($Free -lt $MinLevel) {
|
||||
"⚠️ Swap space of $(MB2String $Total) is nearly full ($(MB2String $Free) free)!"
|
||||
Write-Host "⚠️ Swap space of $(MB2String $Total) is nearly full ($(MB2String $Free) free)!"
|
||||
} elseif ($Used -eq 0) {
|
||||
"✅ Swap space with $(MB2String $Total) reserved"
|
||||
Write-Host "✅ Swap space with $(MB2String $Total) reserved"
|
||||
} elseif ($Used -lt $Free) {
|
||||
"✅ Swap space uses $(MB2String $Used) of $(MB2String $Total)"
|
||||
Write-Host "✅ Swap space uses $(MB2String $Used) of $(MB2String $Total)"
|
||||
} else {
|
||||
"✅ Swap space has $(MB2String $Free) of $(MB2String $Total) free"
|
||||
Write-Host "✅ Swap space has $(MB2String $Free) of $(MB2String $Total) free"
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
|
@ -16,9 +16,9 @@ try {
|
||||
if ($IsLinux) {
|
||||
# TODO
|
||||
} else {
|
||||
$Connections = (Get-VPNConnection)
|
||||
$Connections = Get-VPNConnection
|
||||
foreach($Connection in $Connections) {
|
||||
"✅ VPN '$($Connection.Name)' is $($Connection.ConnectionStatus)"
|
||||
Write-Host "✅ VPN '$($Connection.Name)' is $($Connection.ConnectionStatus)"
|
||||
$NoVPN = $false
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user