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