mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-27 09:08:58 +01:00
Updated some scripts
This commit is contained in:
parent
dc4ee3c83e
commit
a66aa8a009
@ -5,7 +5,7 @@
|
||||
This PowerShell script queries all IP address information and prints it.
|
||||
.EXAMPLE
|
||||
PS> ./list-ip-addresses.ps1
|
||||
✅ Public IP 185.72.229.161, 2003:f2:6128:fd01:e543:601:30c2:a028 near Munich, Germany
|
||||
✅ Internet IP 185.72.229.161, 2003:f2:6128:fd01:e543:601:30c2:a028 near Munich, Germany
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -26,22 +26,20 @@ function WriteLocalInterface($interface) {
|
||||
}
|
||||
}
|
||||
if ($IPv4 -ne "" -or $IPv6 -ne "") {
|
||||
Write-Host "✅ Local $interface IP $IPv4/$prefixLen, $IPv6"
|
||||
"✅ Local $interface IP $IPv4/$prefixLen, $IPv6"
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (!$IsLinux) {
|
||||
WriteLocalInterface "Ethernet"
|
||||
WriteLocalInterface "WLAN"
|
||||
WriteLocalInterface "Bluetooth"
|
||||
}
|
||||
if ($IsLinux) {
|
||||
[string]$publicIPv4 = (curl -4 --silent ifconfig.co)
|
||||
[string]$publicIPv6 = (curl -6 --silent ifconfig.co)
|
||||
[string]$city = (curl --silent ifconfig.co/city)
|
||||
[string]$country = (curl --silent ifconfig.co/country)
|
||||
} else {
|
||||
WriteLocalInterface "Ethernet"
|
||||
WriteLocalInterface "WLAN"
|
||||
WriteLocalInterface "Bluetooth"
|
||||
[string]$publicIPv4 = (curl.exe -4 --silent ifconfig.co)
|
||||
[string]$publicIPv6 = (curl.exe -6 --silent ifconfig.co)
|
||||
[string]$city = (curl.exe --silent ifconfig.co/city)
|
||||
@ -51,7 +49,7 @@ try {
|
||||
if ("$publicIPv6" -eq "") { $publicIPv6 = "no IPv6" }
|
||||
if ("$city" -eq "") { $city = "unknown city" }
|
||||
if ("$country" -eq "") { $country = "unknown country" }
|
||||
Write-Host "✅ Public IP $publicIPv4, $publicIPv6 near $city, $country"
|
||||
"✅ Internet IP $publicIPv4, $publicIPv6 near $city, $country"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -33,10 +33,10 @@ try {
|
||||
}
|
||||
[int]$loss = $total - $success
|
||||
if ($success -eq 0) {
|
||||
Write-Host "⚠️ Offline ($loss/$total ping loss)"
|
||||
Write-Host "⚠️ Internet offline (100% ping loss)"
|
||||
} elseif ($loss -eq 0) {
|
||||
$avg /= $success
|
||||
Write-Host "✅ Online with $($min)...$($max)ms latency - $($avg)ms average"
|
||||
Write-Host "✅ Internet latency $($min)...$($max)ms, average is $($avg)ms"
|
||||
} else {
|
||||
$avg /= $success
|
||||
Write-Host "✅ Online with $loss/$total ping loss and $($min)...$($max)ms latency - $($avg)ms average"
|
||||
|
Loading…
Reference in New Issue
Block a user