Added locate-ipaddress.ps1

This commit is contained in:
Markus Fleschutz 2020-12-09 14:34:55 +00:00
parent dfa6ae3ce0
commit 0352894f9d
2 changed files with 22 additions and 0 deletions

View File

@ -19,6 +19,7 @@ The following PowerShell scripts can be found in the [Scripts/](Scripts/) subfol
* [list-cmdlets.ps1](Scripts/list-cmdlets.ps1) - lists the PowerShell cmdlets
* [list-modules.ps1](Scripts/list-modules.ps1) - lists the PowerShell modules
* [list-processes.ps1](Scripts/list-processes.ps1) - lists the local computer processes
* [locate-ipaddress.ps1](Scripts/locate-ipaddress.ps1) - locates the geographic position of the given IP address
* [MD5.ps1](Scripts/MD5.ps1) - prints the MD5 checksum of the given file
* [make-install.ps1](Scripts/make-install.ps1) - installs built executables and libs to the installation directory
* [moon.ps1](Scripts/moon.ps1) - prints the current moon phase

21
Scripts/locate-ipaddress.ps1 Executable file
View File

@ -0,0 +1,21 @@
#!/snap/bin/powershell
# Syntax: ./locate-ipaddress.ps1 [<IPaddress>]
# Description: locates the geographic position of the given IP address
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([string]$IPaddr)
if ($IPaddr -eq "" ) {
$URL = read-host "Enter IP address to locate"
}
try {
$result = Invoke-RestMethod -Method Get -Uri "http://ip-api.com/json/$IPaddr"
write-host $result
exit 0
} catch {
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}