Geolocate IP
A simple GUI where you type in the IP address and it shows you which country/city/ISP it belongs to.
Finding where in the world an IP address is assigned to doesn't seem like its useful at first. That changes when you check Azure login attempts or odd firewall logs and you want to know if the traffic is legitimate or not. Using the script below you can see if its someone trying to hack your system or a CEO trying to log in while on vacation and getting blocked.
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$form = New-Object System.Windows.Forms.Form
$form.Text = 'PowerShell Form'
$form.Size = New-Object System.Drawing.Size(500, 450)
$form.StartPosition = 'CenterScreen'
$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(10, 20)
$label.Size = New-Object System.Drawing.Size(280, 20)
$label.Text = 'Enter the IP Address:'
$form.Controls.Add($label)
$textBox = New-Object System.Windows.Forms.TextBox
$textBox.Location = New-Object System.Drawing.Point(10, 50)
$textBox.Size = New-Object System.Drawing.Size(260, 20)
$form.Controls.Add($textBox)
$textBox2 = New-Object System.Windows.Forms.TextBox
$textBox2.Multiline = $true
$textBox2.Location = New-Object System.Drawing.Point(10, 100)
$textBox2.Size = New-Object System.Drawing.Size(400, 220)
$form.Controls.Add($textBox2)
$button = New-Object System.Windows.Forms.Button
$button.Location = New-Object System.Drawing.Point(100, 350)
$button.Size = New-Object System.Drawing.Size(100, 30)
$button.Text = 'Submit'
$button.DialogResult = [System.Windows.Forms.DialogResult]::OK
$form.AcceptButton = $button
$form.Controls.Add($button)
$IPaddress = ""
function getiplocation{
param([string]$IPaddress= "")
try {
{ $IPaddress = $textBox.Text }
$result = Invoke-RestMethod -Method Get -Uri "http://ip-api.com/json/$IPaddress"
$textBox2.Text += "Status: " + $result.status + "`r`n"
$textBox2.Text += "Country: " + $result.Country + "`r`n"
$textBox2.Text += "Region: " + $result.region + "`r`n"
$textBox2.Text += "City: " + $result.city + "`r`n"
$textBox2.Text += "ISP: " + $result.ISP
write-host $result
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
}
if ($result -eq [System.Windows.Forms.DialogResult]::OK) {
getiplocation -IPaddress $Textbox.text
}
$result = $form.ShowDialog()
Power in Numbers
Programs
Locations
Volunteers
Project Gallery
