Updated cd-scripts.ps1 and ping-host.ps1

This commit is contained in:
Markus Fleschutz 2024-12-27 15:00:14 +01:00
parent 64bcdee5e8
commit ece41fa2e9
2 changed files with 5 additions and 5 deletions

View File

@ -4,8 +4,8 @@
.DESCRIPTION
This PowerShell script changes the working directory to the PowerShell scripts folder.
.EXAMPLE
PS> ./cd-scripts
📂C:\Users\Markus\Repos\PowerShell\scripts
PS> ./cd-scripts.ps1
📂C:\Repos\PowerShell\scripts
.LINK
https://github.com/fleschutz/PowerShell
.NOTES

View File

@ -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 (20ms latency to IP 104.244.42.65).
Host 'x.com' at IP 104.244.42.1 is up with 20ms latency.
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -22,11 +22,11 @@ try {
[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))."
Write-Output "✅ Host '$hostname' at IP $($ping.Address) is up with $($ping.RoundtripTime)ms latency."
exit 0 # success
}
}
Write-Host "⚠️ Host '$hostname' doesn't respond - check the connection or maybe the host is down (yet)."
Write-Output "⚠️ Host '$hostname' doesn't respond - check the connection or maybe the host is down."
exit 1
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"