mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-29 13:14:49 +02:00
Added locate-ipaddress.ps1
This commit is contained in:
parent
dfa6ae3ce0
commit
0352894f9d
@ -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-cmdlets.ps1](Scripts/list-cmdlets.ps1) - lists the PowerShell cmdlets
|
||||||
* [list-modules.ps1](Scripts/list-modules.ps1) - lists the PowerShell modules
|
* [list-modules.ps1](Scripts/list-modules.ps1) - lists the PowerShell modules
|
||||||
* [list-processes.ps1](Scripts/list-processes.ps1) - lists the local computer processes
|
* [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
|
* [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
|
* [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
|
* [moon.ps1](Scripts/moon.ps1) - prints the current moon phase
|
||||||
|
21
Scripts/locate-ipaddress.ps1
Executable file
21
Scripts/locate-ipaddress.ps1
Executable 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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user