Modules/Geolocalization/geolocalization.psm1
<# .SYNOPSIS Shows location information based on the network. .DESCRIPTION If given without parameters, the ``Get-Geolocation`` cmdlet will return all data retrieved from ip-api.com such as: country, region, city, zip code, co-ordinates, timezone, isp name and ip addres .PARAMETER City Returns the city name of your location. .EXAMPLE Get-Geolocation .EXAMPLE Get-Geolocation -City #> function Get-Geolocation{ [CmdletBinding(HelpUri="https://github.com/akotu235/APS/blob/master/Docs/Modules/Geolocalization/Get-Geolocation.md")] param( [switch]$City ) try{ $Response = Invoke-WebRequest -Uri http://ip-api.com/json/ -DisableKeepAlive -UseBasicParsing } catch{ $Response = @{} $Response.Add('StatusDescription', "Cannot retrieve data.") $Response.Add('StatusCode', "0") } if($Response.StatusCode -like "200"){ $GeolocationData = $Response.Content | ConvertFrom-Json if($City){ return $GeolocationData.city } else{ return $GeolocationData } } else{ return $null } } # SIG # Begin signature block # MIIIWAYJKoZIhvcNAQcCoIIISTCCCEUCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUG4SzJdnK3aSYKMc0BuLkhYSi # WCigggT6MIIE9jCCAt6gAwIBAgIQYYPyfUBBC6pE/rAfOslXOzANBgkqhkiG9w0B # AQsFADATMREwDwYDVQQDDAhha290dSBDQTAeFw0yMjA5MjAxOTQ4MDFaFw0zMjA5 # MjAxOTU4MDFaMBMxETAPBgNVBAMMCGFrb3R1IENBMIICIjANBgkqhkiG9w0BAQEF # AAOCAg8AMIICCgKCAgEAvGcae/FCZugTbghxO7Qv9wQKvRvp9/WvJyJci/SIsPr1 # /Mf5wfBTJ3aCvyjFvHfcsDH4NdHZubHO531tc1NHCDh+Ztkr5hbOdl3x46nEXm6u # e4Fiw23SB02dU3dAnFvNSGEE5jhQDOApGX/u7xEW4ZXrvMC5yLCBa3Kva1abPx5b # owvQlHhi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E+ # 1Vcq8p75ZFsGVwIfmMvk0I77ZBZKM86qKE/AkmHGsCq3K8MbzR5MUQKAFssm/AmJ # 9jY3LhKNW54PLw/SPooOq+FomqP9wsmxwHKJrazH86uCouvk4TgoKXzs8VK9yqNJ # dlokbQ+9zFrpHz+4pCtDE891qjrcoABowydyXw== # SIG # End signature block |