mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-01-06 22:19:09 +01:00
Updated cd-scripts.ps1 and ping-host.ps1
This commit is contained in:
parent
64bcdee5e8
commit
ece41fa2e9
@ -4,8 +4,8 @@
|
|||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script changes the working directory to the PowerShell scripts folder.
|
This PowerShell script changes the working directory to the PowerShell scripts folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-scripts
|
PS> ./cd-scripts.ps1
|
||||||
📂C:\Users\Markus\Repos\PowerShell\scripts
|
📂C:\Repos\PowerShell\scripts
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
Specifies the hostname or IP address to ping (x.com by default)
|
Specifies the hostname or IP address to ping (x.com by default)
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./ping-host.ps1 x.com
|
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
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -22,11 +22,11 @@ try {
|
|||||||
[Threading.Tasks.Task]::WaitAll($tasks)
|
[Threading.Tasks.Task]::WaitAll($tasks)
|
||||||
foreach($ping in $tasks.Result) {
|
foreach($ping in $tasks.Result) {
|
||||||
if ($ping.Status -eq "Success") {
|
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
|
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
|
exit 1
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user