mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-21 20:21:21 +01:00
Merge branch 'main' of github.com:fleschutz/PowerShell
This commit is contained in:
commit
7069c2c31b
@ -441,6 +441,7 @@ RSC,Runway Surface Condition
|
||||
RSI,Remote Status Indicator
|
||||
RSO,Range Safety Officer
|
||||
RSRS,Reduced Same Runway Separation
|
||||
RSU,Runway Supervisory Unit
|
||||
RTAF,Royal Thai Air Force
|
||||
RTCA,Radio Technical Commission for Aeronautics
|
||||
RTF,Radio Telephony
|
||||
@ -548,6 +549,7 @@ TRA,Temporary Reserved Area
|
||||
TRACON,Terminal Radar Approach Control
|
||||
TRH,Thrust Reduction Height
|
||||
TSA,Temporary Segregated Area
|
||||
TSAT,Target Startup Approval Time
|
||||
TSO,Technical Standard Order
|
||||
TSTC,Texas State Technical College
|
||||
TT,True Track
|
||||
|
Can't render this file because it has a wrong number of fields in line 139.
|
@ -7,7 +7,8 @@
|
||||
Specifies the folder name of the Git repository
|
||||
.EXAMPLE
|
||||
PS> ./cd-repo.ps1 rust
|
||||
📂C:\Repos\rust · on branch: ## main ... origin/main
|
||||
📂C:\Repos\rust
|
||||
🌿on branch: ## main ... origin/main
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -38,7 +39,7 @@ try {
|
||||
|
||||
$path = Resolve-Path "$path"
|
||||
Set-Location "$path"
|
||||
Write-Host "📂$path · on branch: " -noNewline
|
||||
Write-Host "📂$path`n🌿on branch: " -noNewline
|
||||
& git status --short --branch --show-stash
|
||||
exit 0 # success
|
||||
} catch {
|
||||
|
@ -5,7 +5,7 @@
|
||||
This PowerShell script queries the status of the SSD/HDD devices (supporting S.M.A.R.T.) and prints it.
|
||||
.EXAMPLE
|
||||
PS> ./check-smart-devices.ps1
|
||||
✅ 1TB Samsung SSD 970 EVO via NVMe (37°C, 2388 hours, 289x on/off, v2B2QEXE7, test passed)
|
||||
✅ 1TB Samsung SSD 970 EVO 1TB via NVMe (35°C, 6142h, 34TB read, 64TB written, 770x on/off, v2B2QEXE7, test passed)
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -29,18 +29,15 @@ function Bytes2String([int64]$bytes) {
|
||||
}
|
||||
|
||||
try {
|
||||
#Write-Progress "(1/3) Searching for smartmontools..."
|
||||
$result = (smartctl --version)
|
||||
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..."
|
||||
if ($IsLinux) {
|
||||
$devices = $(sudo smartctl --scan-open)
|
||||
} else {
|
||||
$devices = $(smartctl --scan-open)
|
||||
}
|
||||
|
||||
#Write-Progress "Querying S.M.A.R.T devices..."
|
||||
foreach($device in $devices) {
|
||||
$array = $device.split(" ")
|
||||
$dev = $array[0]
|
||||
@ -62,37 +59,41 @@ try {
|
||||
} else {
|
||||
$capacity = ""
|
||||
}
|
||||
$infos = ""
|
||||
if ($details.temperature.current -gt 50) {
|
||||
$temp = "$($details.temperature.current)°C TOO HOT"
|
||||
$infos = "$($details.temperature.current)°C TOO HOT"
|
||||
$status = "⚠️"
|
||||
} elseif ($details.temperature.current -lt 0) {
|
||||
$temp = "$($details.temperature.current)°C TOO COLD"
|
||||
$infos = "$($details.temperature.current)°C TOO COLD"
|
||||
$status = "⚠️"
|
||||
} else {
|
||||
$temp = "$($details.temperature.current)°C"
|
||||
$infos = "$($details.temperature.current)°C"
|
||||
}
|
||||
if ($details.power_on_time.hours -gt 87600) { # 10 years
|
||||
$hours = "$($details.power_on_time.hours) hours (!)"
|
||||
$infos += ", $($details.power_on_time.hours)h (!)"
|
||||
$status = "⚠️"
|
||||
} else {
|
||||
$hours = "$($details.power_on_time.hours) hours"
|
||||
$infos += ", $($details.power_on_time.hours)h"
|
||||
}
|
||||
if ($details.nvme_smart_health_information_log.host_reads) {
|
||||
$infos += ", $(Bytes2String ($details.nvme_smart_health_information_log.data_units_read * 512 * 1000)) read"
|
||||
$infos += ", $(Bytes2String ($details.nvme_smart_health_information_log.data_units_written * 512 * 1000)) written"
|
||||
}
|
||||
if ($details.power_cycle_count -gt 100000) {
|
||||
$powerOn = "$($details.power_cycle_count)x on/off (!)"
|
||||
$infos += ", $($details.power_cycle_count)x on/off (!)"
|
||||
$status = "⚠️"
|
||||
} else {
|
||||
$powerOn = "$($details.power_cycle_count)x on/off"
|
||||
}
|
||||
$infos += ", $($details.power_cycle_count)x on/off"
|
||||
}
|
||||
$infos += ", v$($details.firmware_version)"
|
||||
if ($details.smart_status.passed) {
|
||||
$selftest = "test passed"
|
||||
$infos += ", test passed"
|
||||
} else {
|
||||
$selftest = "test FAILED"
|
||||
$infos += ", test FAILED"
|
||||
$status = "⚠️"
|
||||
}
|
||||
$firmwareVersion = $details.firmware_version
|
||||
Write-Host "$status $capacity$modelName via $protocol ($temp, $hours, $powerOn, v$firmwareVersion, $selftest)"
|
||||
Write-Host "$status $capacity$modelName via $protocol ($infos)"
|
||||
}
|
||||
#Write-Progress -completed "Done."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -12,7 +12,7 @@
|
||||
⏳ (2/4) Checking local repository... C:\Repos\rust
|
||||
⏳ (3/4) Removing untracked files in repository...
|
||||
⏳ (4/4) Removing untracked files in submodules...
|
||||
✅ Repo 📂rust successfully cleaned up in 2s.
|
||||
✅ Cleaned up repo 📂rust in 2s.
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -45,7 +45,7 @@ try {
|
||||
if ($lastExitCode -ne "0") { throw "'git clean' in the submodules failed with exit code $lastExitCode" }
|
||||
|
||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||
"✅ Repo 📂$repoName successfully cleaned up in $($elapsed)s."
|
||||
"✅ Cleaned up repo 📂$repoName in $($elapsed)s."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -8,7 +8,7 @@
|
||||
.EXAMPLE
|
||||
PS> ./list-earthquakes.ps1
|
||||
|
||||
Mag Location Depth Time UTC
|
||||
MAG LOCATION DEPTH TIME UTC
|
||||
--- -------- ----- --------
|
||||
7.2 98 km S of Sand Point, Alaska 33 km 2023-07-16T06:48:22.606Z
|
||||
...
|
||||
@ -30,13 +30,13 @@ function ListEarthquakes {
|
||||
|
||||
foreach($quake in $quakes) {
|
||||
[int]$depth = $quake.depth
|
||||
New-Object PSObject -Property @{ Mag=$quake.mag; Depth="$depth km"; Location=$quake.place; 'Time UTC'=$quake.time }
|
||||
New-Object PSObject -Property @{ MAG=$quake.mag; DEPTH="$depth km"; LOCATION=$quake.place; 'TIME UTC'=$quake.time }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
ListEarthquakes | Format-Table -property @{e='Mag';width=5},@{e='Location';width=42},@{e='Depth';width=12},'Time UTC'
|
||||
ListEarthquakes | Format-Table -property @{e='MAG';width=5},@{e='LOCATION';width=50},@{e='DEPTH';width=8},'TIME UTC'
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -7,7 +7,7 @@
|
||||
Specifies the hostname or IP address to ping (x.com by default)
|
||||
.EXAMPLE
|
||||
PS> ./ping-host.ps1 x.com
|
||||
✅ Host 'x.com' is up with 23ms ping latency.
|
||||
✅ Host 'x.com' is UP (20ms latency to IP 104.244.42.65).
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -16,22 +16,18 @@
|
||||
|
||||
param([string]$hostname = "x.com")
|
||||
|
||||
function GetPingLatency([string]$hostname) {
|
||||
$hostsArray = $hostname.Split(",")
|
||||
$tasks = $hostsArray | foreach { (New-Object Net.NetworkInformation.Ping).SendPingAsync($_,3000) }
|
||||
[Threading.Tasks.Task]::WaitAll($tasks)
|
||||
foreach($ping in $tasks.Result) { if ($ping.Status -eq "Success") { return $ping.RoundtripTime } }
|
||||
return -1
|
||||
}
|
||||
|
||||
try {
|
||||
[int]$latency = GetPingLatency($hostname)
|
||||
if ($latency -lt 0) {
|
||||
Write-Host "⚠️ Host '$hostname' doesn't respond - check the connection or maybe the host is down."
|
||||
exit 1
|
||||
}
|
||||
Write-Host "✅ Host '$hostname' is up with $($latency)ms ping latency."
|
||||
exit 0 # success
|
||||
$remoteHosts = $hostname.Split(",")
|
||||
$tasks = $remoteHosts | foreach { (New-Object Net.NetworkInformation.Ping).SendPingAsync($_,3000) }
|
||||
[Threading.Tasks.Task]::WaitAll($tasks)
|
||||
foreach($ping in $tasks.Result) {
|
||||
if ($ping.Status -eq "Success") {
|
||||
Write-Host "✅ Host '$hostname' is UP ($($ping.RoundtripTime)ms latency to IP $($ping.Address))."
|
||||
exit 0 # success
|
||||
}
|
||||
}
|
||||
Write-Host "⚠️ Host '$hostname' doesn't respond - check the connection or maybe the host is down (yet)."
|
||||
exit 1
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
|
Loading…
Reference in New Issue
Block a user