Last active
August 29, 2015 14:26
-
-
Save Mukesh05/2f3fb5a9bed173ec3549 to your computer and use it in GitHub Desktop.
Use of WebClient Class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Use of WebClient Class | |
$webClient = New-Object System.Net.WebClient | |
$webClient.DownloadString("http://www.telize.com/geoip")| ConvertFrom-Json | Select-Object longitude,latitude,country_code,timezone | Format-Table -AutoSize | |
#This is a simple function to wrap the above | |
$webClient = New-Object System.Net.WebClient | |
$url="http://www.telize.com/geoip" | |
function Get-GeoInformation | |
{ | |
[CmdletBinding()] | |
param | |
( | |
[string]$url | |
) | |
try | |
{ | |
$out=$webClient.DownloadString("$url") | |
$out | |
} | |
catch [Exception] | |
{ | |
throw $_.Exception.Message | |
} | |
} | |
Get-GeoInformation $url| ConvertFrom-Json | Select-Object longitude,latitude,country_code,timezone |Format-Table -AutoSize |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment