mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-01-22 21:58:42 +01:00
Update some check-*.ps1 scripts
This commit is contained in:
parent
fbd44c0c28
commit
34d6adef57
@ -2,7 +2,7 @@
|
||||
.SYNOPSIS
|
||||
Query app details
|
||||
.DESCRIPTION
|
||||
This PowerShell script queries application details and list it.
|
||||
This PowerShell script queries application details and lists it.
|
||||
.EXAMPLE
|
||||
PS> ./check-apps
|
||||
.LINK
|
||||
@ -15,18 +15,18 @@ try {
|
||||
if ($IsLinux) {
|
||||
# TODO
|
||||
} else {
|
||||
Write-Progress "⏳ Querying installed apps..."
|
||||
Write-Progress "⏳ Querying installed applications..."
|
||||
$Apps = Get-AppxPackage
|
||||
[int]$NumInstalled = $Apps.Count
|
||||
[int]$NumNonOk = 0
|
||||
foreach($App in $Apps) { if ($App.Status -ne "Ok") { $NumNonOk++ } }
|
||||
|
||||
Write-Progress "⏳ Querying available updates..."
|
||||
Write-Progress "⏳ Querying application updates..."
|
||||
$NumUpdates = (winget upgrade --include-unknown).Count - 5
|
||||
|
||||
[int]$NumErrors = (Get-AppxLastError)
|
||||
Write-Host "✅ $NumInstalled apps ($NumNonOk non-ok, $NumErrors errors, $NumUpdates updates available)"
|
||||
Write-Progress -Completed " "
|
||||
Write-Progress -Completed "Querying application updates finished."
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
|
@ -1,8 +1,8 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Checks BIOS details
|
||||
Checks the BIOS
|
||||
.DESCRIPTION
|
||||
This PowerShell script queries and prints BIOS details.
|
||||
This PowerShell script queries the BIOS status and prints it.
|
||||
.EXAMPLE
|
||||
PS> ./check-bios
|
||||
✅ F6 BIOS by American Megatrends Inc. (S/N NXA82EV0EBB0760, version ALASKA - 1072009)
|
||||
@ -13,7 +13,7 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
Write-Progress "Querying BIOS details..."
|
||||
Write-Progress "⏳ Querying BIOS details..."
|
||||
if ($IsLinux) {
|
||||
$Model = (sudo dmidecode -s system-product-name)
|
||||
if ("$Model" -ne "") {
|
||||
@ -30,9 +30,9 @@ try {
|
||||
$Version = $BIOS.Version.Trim()
|
||||
Write-Host "✅ $Model BIOS by $Manufacturer (S/N $Serial, version $Version)"
|
||||
}
|
||||
Write-Progress -Completed " "
|
||||
Write-Progress -completed "BIOS query finished."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
}
|
@ -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) {
|
||||
@ -75,7 +75,7 @@ try {
|
||||
}
|
||||
$Cores = [System.Environment]::ProcessorCount
|
||||
Write-Host "$Status $CPUName ($Cores cores, $($DeviceID)$($Speed)$($Socket)$Temp)"
|
||||
Write-Progress -Completed " "
|
||||
Write-Progress -completed "Querying CPU details finished."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -32,7 +32,7 @@ try {
|
||||
} else {
|
||||
Write-Host "⚠️ DNS resolution is $Average domains per second only!"
|
||||
}
|
||||
Write-Progress -Completed " "
|
||||
Write-Progress -completed "DNS checked."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -1,8 +1,8 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Check the firewall
|
||||
Checks the firewall
|
||||
.DESCRIPTION
|
||||
This PowerShell script queries and prints firewall details.
|
||||
This PowerShell script queries the status of the firewall and prints it.
|
||||
.EXAMPLE
|
||||
PS> ./check-firewall
|
||||
✅ Firewall enabled
|
||||
@ -24,7 +24,6 @@ try {
|
||||
Write-Host "⚠️ Firewall disabled"
|
||||
}
|
||||
}
|
||||
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -2,7 +2,7 @@
|
||||
.SYNOPSIS
|
||||
Check for pending reboots
|
||||
.DESCRIPTION
|
||||
This PowerShell script checks different registry keys and values to determine if a reboot is pending.
|
||||
This PowerShell script queries pending reboots and prints it.
|
||||
.EXAMPLE
|
||||
./check-pending-reboot.ps1
|
||||
.LINK
|
||||
@ -70,4 +70,4 @@ try {
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
param([string]$hosts = "amazon.com,bing.com,cnn.com,dropbox.com,facebook.com,google.com,live.com,twitter.com,youtube.com")
|
||||
|
||||
try {
|
||||
Write-Progress "⏳ Pinging $hosts..."
|
||||
Write-Progress "⏳ Pinging hosts in parallel..."
|
||||
$HostsArray = $hosts.Split(",")
|
||||
$Pings = Test-Connection -computerName $HostsArray -count 1
|
||||
|
||||
@ -33,7 +33,7 @@ try {
|
||||
$Avg /= $Pings.count
|
||||
|
||||
Write-Host "✅ Ping latency is $($Min)ms...$($Max)ms, $($Avg)ms average"
|
||||
Write-Progress -Completed " "
|
||||
Write-Progress -Completed "Ping finished."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -1,8 +1,8 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Query PowerShell details
|
||||
Check the PowerShell
|
||||
.DESCRIPTION
|
||||
This PowerShell script queries and lists details of PowerShell.
|
||||
This PowerShell script queries PowerShell details and lists it.
|
||||
.EXAMPLE
|
||||
PS> ./check-powershell
|
||||
.LINK
|
||||
@ -17,11 +17,12 @@ try {
|
||||
$NumModules = (Get-Module).Count
|
||||
$NumAliases = (Get-Alias).Count
|
||||
if ($IsLinux) {
|
||||
"✅ PowerShell $Version ($Edition edition, $NumModules modules, $NumAliases aliases)"
|
||||
$Reply = "✅ PowerShell $Version ($Edition edition, $NumModules modules, $NumAliases aliases)"
|
||||
} else {
|
||||
$NumCmdlets = (Get-Command -Command-Type cmdlet).Count
|
||||
"✅ PowerShell $Version ($Edition edition, $NumModules modules, $NumCmdlets cmdlets, $NumAliases aliases)"
|
||||
$Reply = "✅ PowerShell $Version ($Edition edition, $NumModules modules, $NumCmdlets cmdlets, $NumAliases aliases)"
|
||||
}
|
||||
Write-Host $Reply
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -2,7 +2,7 @@
|
||||
.SYNOPSIS
|
||||
Checks the swap space
|
||||
.DESCRIPTION
|
||||
This PowerShell script checks the free swap space.
|
||||
This PowerShell script queries the status of the swap space and prints it.
|
||||
.PARAMETER MinLevel
|
||||
Specifies the minimum level (10 GB by default)
|
||||
.EXAMPLE
|
||||
@ -44,18 +44,19 @@ try {
|
||||
}
|
||||
}
|
||||
if ($Total -eq 0) {
|
||||
Write-Host "⚠️ No swap space configured!"
|
||||
$Reply = "⚠️ No swap space configured!"
|
||||
} elseif ($Free -eq 0) {
|
||||
Write-Host "⚠️ Swap space of $(MB2String $Total) is full!"
|
||||
$Reply = "⚠️ Swap space of $(MB2String $Total) is full!"
|
||||
} elseif ($Free -lt $MinLevel) {
|
||||
Write-Host "⚠️ Swap space of $(MB2String $Total) is nearly full ($(MB2String $Free) free)!"
|
||||
$Reply = "⚠️ Swap space of $(MB2String $Total) is nearly full ($(MB2String $Free) free)!"
|
||||
} elseif ($Used -eq 0) {
|
||||
Write-Host "✅ Swap space with $(MB2String $Total) reserved"
|
||||
$Reply = "✅ Swap space with $(MB2String $Total) reserved"
|
||||
} elseif ($Used -lt $Free) {
|
||||
Write-Host "✅ Swap space uses $(MB2String $Used) of $(MB2String $Total)"
|
||||
$Reply = "✅ Swap space uses $(MB2String $Used) of $(MB2String $Total)"
|
||||
} else {
|
||||
Write-Host "✅ Swap space has $(MB2String $Free) of $(MB2String $Total) free"
|
||||
$Reply = "✅ Swap space has $(MB2String $Free) of $(MB2String $Total) free"
|
||||
}
|
||||
Write-Host $Reply
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -18,7 +18,7 @@ try {
|
||||
$BootTime = Get-WinEvent -ProviderName eventlog | Where-Object {$_.Id -eq 6005} | Select-Object TimeCreated -First 1
|
||||
$Uptime = New-TimeSpan -Start $BootTime.TimeCreated.Date -End (Get-Date)
|
||||
}
|
||||
$Reply = "Up for "
|
||||
$Reply = "✅ Up for "
|
||||
$Days = $Uptime.Days
|
||||
if ($Days -eq "1") {
|
||||
$Reply += "1 day, "
|
||||
@ -39,7 +39,7 @@ try {
|
||||
} else {
|
||||
$Reply += "$Minutes minutes"
|
||||
}
|
||||
Write-Host "✅ $Reply."
|
||||
Write-Host $Reply
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -2,7 +2,7 @@
|
||||
.SYNOPSIS
|
||||
Checks the VPN connection
|
||||
.DESCRIPTION
|
||||
This PowerShell script queries and prints the status of any VPN connection.
|
||||
This PowerShell script queries status of the VPN connections and prints it.
|
||||
.EXAMPLE
|
||||
PS> ./check-vpn
|
||||
.LINK
|
||||
@ -22,7 +22,7 @@ try {
|
||||
$NoVPN = $false
|
||||
}
|
||||
}
|
||||
if ($NoVPN) { "⚠️ No VPN connection" }
|
||||
if ($NoVPN) { Write-Host "⚠️ No VPN connection" }
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Loading…
Reference in New Issue
Block a user