mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-27 09:08:58 +01:00
Update list-public-ip.ps1
This commit is contained in:
parent
ced7359b6d
commit
f79c6d843a
@ -5,7 +5,7 @@
|
||||
This PowerShell script queries the public IP address(es) and prints it.
|
||||
.EXAMPLE
|
||||
PS> ./list-public-ip.ps1
|
||||
✅ Public IPv4 185.72.209.161, IPv6 2003:f2:6128:fc01:e503:601:30c2:a028 near Munich
|
||||
✅ Public IP address 185.72.209.161, 2003:f2:6128:fc01:e503:601:30c2:a028 near Munich
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -22,10 +22,10 @@ try {
|
||||
$publicIPv6 = (curl.exe -6 --silent ifconfig.co)
|
||||
$city = (curl.exe --silent ifconfig.co/city)
|
||||
}
|
||||
if ("$publicIPv4" -eq "") { $publicIPv4 = "N/A" }
|
||||
if ("$publicIPv6" -eq "") { $publicIPv6 = "N/A" }
|
||||
if ("$publicIPv4" -eq "") { $publicIPv4 = "no IPv4" }
|
||||
if ("$publicIPv6" -eq "") { $publicIPv6 = "no IPv6" }
|
||||
if ("$city" -eq "") { $city = "unknown" }
|
||||
Write-Output "✅ Public IPv4 $publicIPv4, IPv6 $publicIPv6 near $City"
|
||||
Write-Output "✅ Public IP address $publicIPv4, $publicIPv6 near $City"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Loading…
Reference in New Issue
Block a user