mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-26 19:58:45 +02:00
Add output of country
This commit is contained in:
parent
f943a8ae91
commit
3d8e7fbad8
@ -1,11 +1,11 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Lists the public IP address(es)
|
Lists the public IP address information
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script queries the public IP address(es) and prints it.
|
This PowerShell script queries the public IP address information and prints it.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./list-public-ip.ps1
|
PS> ./list-public-ip.ps1
|
||||||
✅ Public IP address 185.72.209.161, 2003:f2:6128:fc01:e503:601:30c2:a028 near Munich
|
✅ Public IP address 185.72.229.161, 2003:f2:6128:fc01:e543:601:30c2:a028 near Munich, Germany
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -14,18 +14,21 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if ($IsLinux) {
|
if ($IsLinux) {
|
||||||
$publicIPv4 = (curl -4 --silent ifconfig.co)
|
[string]$publicIPv4 = (curl -4 --silent ifconfig.co)
|
||||||
$publicIPv6 = (curl -6 --silent ifconfig.co)
|
[string]$publicIPv6 = (curl -6 --silent ifconfig.co)
|
||||||
$city = (curl --silent ifconfig.co/city)
|
[string]$city = (curl --silent ifconfig.co/city)
|
||||||
|
[string]$country = (curl --silent ifconfig.co/country)
|
||||||
} else {
|
} else {
|
||||||
$publicIPv4 = (curl.exe -4 --silent ifconfig.co)
|
[string]$publicIPv4 = (curl.exe -4 --silent ifconfig.co)
|
||||||
$publicIPv6 = (curl.exe -6 --silent ifconfig.co)
|
[string]$publicIPv6 = (curl.exe -6 --silent ifconfig.co)
|
||||||
$city = (curl.exe --silent ifconfig.co/city)
|
[string]$city = (curl.exe --silent ifconfig.co/city)
|
||||||
|
[string]$country = (curl.exe --silent ifconfig.co/country)
|
||||||
}
|
}
|
||||||
if ("$publicIPv4" -eq "") { $publicIPv4 = "no IPv4" }
|
if ("$publicIPv4" -eq "") { $publicIPv4 = "no IPv4" }
|
||||||
if ("$publicIPv6" -eq "") { $publicIPv6 = "no IPv6" }
|
if ("$publicIPv6" -eq "") { $publicIPv6 = "no IPv6" }
|
||||||
if ("$city" -eq "") { $city = "unknown" }
|
if ("$city" -eq "") { $city = "unknown city" }
|
||||||
Write-Output "✅ Public IP address $publicIPv4, $publicIPv6 near $City"
|
if ("$country" -eq "") { $country = "unknown country" }
|
||||||
|
Write-Output "✅ Public IP address $publicIPv4, $publicIPv6 near $city, $country" ; if ($country -eq "Russia") { Write-Host -foregroundColor red "DON'T TRUST PUTIN !!! FLEE NOW OR DIE AS SOLDIER IN UKRAINE !!!" }
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user