{"id":4252,"date":"2015-02-19T10:03:14","date_gmt":"2015-02-19T15:03:14","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=4252"},"modified":"2015-02-19T10:10:20","modified_gmt":"2015-02-19T15:10:20","slug":"a-powershell-weather-service","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4252\/a-powershell-weather-service\/","title":{"rendered":"A PowerShell Weather Service"},"content":{"rendered":"<p>I've been having some fun this week sharing a few tools for getting weather information and forecasts using PowerShell. To complete the story, today I have one more technique. Using PowerShell, you can query a web service for weather information. In simple terms a web service is like an application you can \"run\" via a web connection and sometimes even in a browser. The web service has \"methods\" you can invoke to do something. In the past if you wanted to interact with a web service in PowerShell you most likely needed to get down and dirty with the .NET Framework. Then PowerShell 3.0 brought us a new cmdlet, New-WebServiceProxy. With this cmdlet you can create an object that in essence becomes a wrapper to the web service. The web service methods become the object's methods. Let me show you.<\/p>\n<p>First, I'll create my proxy object.<\/p>\n<pre><code>$proxy = New-WebServiceProxy -uri http:\/\/www.webservicex.com\/globalweather.asmx?WSDL<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/02\/021915_1502_APowerShell1.png\" alt=\"\" \/><\/p>\n<p>This object also has methods:<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/02\/021915_1502_APowerShell2.png\" alt=\"\" \/><\/p>\n<p>So how do I use the GetWeather method?<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/02\/021915_1502_APowerShell3.png\" alt=\"\" \/><\/p>\n<p>Seems straight forward. Let's try. Wonder what it is like someplace warm?<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/02\/021915_1502_APowerShell4.png\" alt=\"\" \/><\/p>\n<p>Interesting. I can read it, but this sure looks like XML. If so, I should be able to retrieve the weather as an XML document.<\/p>\n<pre><code>[xml]$current = $proxy.GetWeather(\"Miami\",\"United States\")<\/code><\/pre>\n<p>Now I can explore it.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/02\/021915_1502_APowerShell5.png\" alt=\"\" \/><\/p>\n<p>Wow. This seems simple. All I need is the CurrentWeather property and I have an easy to read result. I could probably run this as a one-liner.<\/p>\n<pre><code>([xml]((New-WebServiceProxy -uri http:\/\/www.webservicex.com\/globalweather.asmx?WSDL).GetWeather(\"Fairbanks\",\"United States\"))).CurrentWeather<\/code><\/pre>\n<p>Not necessarily easy to read but it works.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/02\/021915_1502_APowerShell6.png\" alt=\"\" \/><\/p>\n<p>What about another city? Perhaps Charlotte, North Carolina, the site of the upcoming PowerShell Summit.<\/p>\n<pre><code>([xml]((New-WebServiceProxy -uri http:\/\/www.webservicex.com\/globalweather.asmx?WSDL).GetWeather(\"Charlotte\",\"United States\"))).CurrentWeather<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/02\/021915_1502_APowerShell7.png\" alt=\"\" \/><\/p>\n<p>Well that worked, but that isn't the city I had in mind. Going back to the web service methods, I remember seeing something to get cities by country. Let's try that.<\/p>\n<pre><code>$proxy.GetCitiesByCountry(\"Nepal\")<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/02\/021915_1502_APowerShell8.png\" alt=\"\" \/><\/p>\n<p>More XML. That's find. I can use Select-XML to parse out the City node.<\/p>\n<pre><code>$proxy.GetCitiesByCountry(\"Nepal\") | select-xml \"\/\/City\"<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/02\/021915_1502_APowerShell9.png\" alt=\"\" \/><\/p>\n<p>Now, expand each node.<\/p>\n<pre><code>$proxy.GetCitiesByCountry(\"Nepal\") | select-xml \"\/\/City\" | select -expand node<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/02\/021915_1502_APowerShell10.png\" alt=\"\" \/><\/p>\n<p>Let's try with the US now and find cities with Charlotte in the name.<\/p>\n<pre><code>$proxy.GetCitiesByCountry(\"United States\") | select-xml \"\/\/City\" | select -expand node | Where {$_.'#text' -match \"Charlotte\"}<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/02\/021915_1502_APowerShell11.png\" alt=\"\" \/><\/p>\n<p>It seems to me that the weather service data comes primarily from locations with airports. So if you live in a town without an airport, the best you can probably do is find a location near you with an airport. But now that I see what I need for Charlotte, North Carolina, I can revise my command.<\/p>\n<pre><code>([xml]((New-WebServiceProxy -uri http:\/\/www.webservicex.com\/globalweather.asmx?WSDL).GetWeather(\"Charlotte \/ Douglas\",\"United States\"))).CurrentWeather<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/02\/021915_1502_APowerShell12.png\" alt=\"\" \/><\/p>\n<p>Much better. But I don't want to have to do that much typing for all of this so I put together a few functions to simplify the entire process. First, is a function to get a location.<\/p>\n<pre class=\"lang:ps decode:true \">Function Get-WeatherLocation {\r\n\r\n&lt;#\r\n.SYNOPSIS\r\nGet weather locations via web service proxy\r\n.DESCRIPTION\r\nThis command will get all cities for a given country using a web service proxy designed to retrieve weather conditions.\r\n.PARAMETER Country\r\nThe name of the country in English. \r\n.PARAMETER City\r\nSome portion of the name of a city or area. The command will match on the pattern so regular expressions are permitted.\r\n.EXAMPLE\r\nPS C:\\&gt; Get-WeatherLocation Albania\r\n\r\nCity                                         Country\r\n----                                         -------\r\nTirana                                       Albania\r\n\r\n.EXAMPLE\r\nPS C:\\&gt; Get-Weatherlocation -city \"chicago\"\r\n\r\n\r\nCity                                         Country                                    \r\n----                                         -------                                    \r\nChicago \/ Meigs                              United States                              \r\nChicago \/ West Chicago, Dupage Airport       United States                              \r\nChicago, Chicago Midway Airport              United States                              \r\nChicago, Chicago-O'Hare International Air... United States                              \r\nChicago \/ Wheeling, Pal-Waukee Airport       United States                              \r\nChicago \/ Waukegan                           United States                              \r\n\r\nFind all US locations that have \"Chicago\" in the name.\r\n\r\n.NOTES\r\nNAME        :  Get-WeatherLocation\r\nVERSION     :  1.0   \r\nLAST UPDATED:  2\/19\/2015\r\nAUTHOR      :  Jeff Hicks\r\n\r\nLearn more about PowerShell:\r\n<blockquote class=\"wp-embedded-content\" data-secret=\"7zQe85bKxX\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/essential-powershell-resources\/\">Essential PowerShell Learning Resources<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Essential PowerShell Learning Resources&#8221; &#8212; The Lonely Administrator\" src=\"https:\/\/jdhitsolutions.com\/blog\/essential-powershell-resources\/embed\/#?secret=zFd4lUahdt#?secret=7zQe85bKxX\" data-secret=\"7zQe85bKxX\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\r\n\r\n  ****************************************************************\r\n  * DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED *\r\n  * THOROUGHLY IN A LAB ENVIRONMENT. USE AT YOUR OWN RISK.  IF   *\r\n  * YOU DO NOT UNDERSTAND WHAT THIS SCRIPT DOES OR HOW IT WORKS, *\r\n  * DO NOT USE IT OUTSIDE OF A SECURE, TEST SETTING.             *\r\n  ****************************************************************\r\n.LINK\r\nNew-WebServiceProxy \r\n.INPUTS\r\nNone\r\n.OUTPUTS\r\nCustom object\r\n#&gt;\r\n[cmdletbinding()]\r\nParam(\r\n[Parameter(Position=0,ValueFromPipeline)]\r\n[ValidateNotNullorEmpty()]\r\n[string]$Country=\"United States\",\r\n[string]$City\r\n\r\n)\r\nBegin {\r\n    Write-Verbose -Message \"Starting $($MyInvocation.Mycommand)\"  \r\n    Try {\r\n        #hashtable of parameters to splat to New-WebServiceProxy\r\n        $paramHash = @{\r\n         uri = 'http:\/\/www.webservicex.com\/globalweather.asmx?WSDL'\r\n         ErrorAction = 'Stop'\r\n        }\r\n        Write-Verbose \"Creating web proxy to $($paramHash.uri)\"\r\n        $webproxy = New-WebServiceProxy @paramHash    \r\n    }\r\n    Catch {\r\n        Throw $_\r\n    }\r\n} #begin\r\n\r\nProcess {\r\n    If ($webproxy) {\r\n        [xml]$cities = $webproxy.GetCitiesbyCountry($Country)\r\n        #only continue if there is data to process\r\n        if ($cities.NewDataset) {\r\n            #this will write a new object to the pipeline with 2 properties\r\n            $data = $cities.NewDataSet.table | select City,Country\r\n        }\r\n        Else {\r\n            Write-Warning \"Failed to retrieve cities for $country\"\r\n        }\r\n\r\n        if ($City) {\r\n            $data | where {$_.city -match $City}\r\n        }\r\n        else {\r\n           #write all data to the pipeline \r\n           $data\r\n        }\r\n    } #if webproxy\r\n} #process\r\nEnd {\r\n    Write-Verbose -Message \"Ending $($MyInvocation.Mycommand)\"\r\n} #end\r\n\r\n} #end function\r\n\r\nSet-Alias -Name gwl -Value Get-WeatherLocation<\/pre>\n<p>The function does all the work of creating the web service proxy and retrieving cities by country. You can change the default to your country. I also added a parameter that will match on a city name.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/02\/021915_1502_APowerShell13.png\" alt=\"\" \/><\/p>\n<p>I then wrote a function to make it easier to get weather information.<\/p>\n<pre class=\"lang:ps decode:true \" >Function Get-WeatherByProxy {\r\n&lt;#\r\n.SYNOPSIS\r\nGet weather conditions via a web service proxy\r\n.DESCRIPTION\r\nThis command uses the New-WebServiceProxy cmdlet to retrieve weather information from a web service.\r\n.PARAMETER City\r\nThe name of the city or location. This works best if the city has an airport. You can also use part of the airport name.\r\n.PARAMETER Country\r\nThe name of the country in English.\r\n\r\n.EXAMPLE\r\nPS C:\\&gt; Get-Weatherbyproxy Seattle\r\n\r\nLocation         : SEATTLE-TACOMA INTERNATIONAL  AIRPORT , WA, United States (KSEA) \r\n                   47-27N 122-19W 136M\r\nTime             : Feb 18, 2015 - 08:53 AM EST \/ 2015.02.18 1353 UTC\r\nWind             : from the SE (130 degrees) at 8 MPH (7 KT):0\r\nVisibility       : 10 mile(s):0\r\nSkyConditions    : partly cloudy\r\nTemperature      : 43.0 F (6.1 C)\r\nDewPoint         : 39.0 F (3.9 C)\r\nRelativeHumidity : 85%\r\nPressure         : 30.18 in. Hg (1022 hPa)\r\nStatus           : Success\r\n\r\nGet the weather in Seattle.\r\n.EXAMPLE\r\nPS C:\\&gt; Get-WeatherbyProxy \"O'Hare\" | Select Time,Sky*,Temperature\r\n\r\nTime                          SkyConditions                 Temperature                 \r\n----                          -------------                 -----------                 \r\nFeb 18, 2015 - 09:51 AM ES... partly cloudy                 5.0 F (-15.0 C)\r\n\r\nGet the weather in Chicago using O'Hare airport as the source.\r\n.EXAMPLE\r\nPS C:\\&gt; Get-Weatherbyproxy Oslo Norway\r\n\r\nLocation         : Oslo \/ Gardermoen, Norway (ENGM) 60-12N 011-05E 204M\r\nTime             : Feb 18, 2015 - 09:50 AM EST \/ 2015.02.18 1450 UTC\r\nWind             : from the S (190 degrees) at 12 MPH (10 KT):0\r\nVisibility       : greater than 7 mile(s):0\r\nSkyConditions    : mostly cloudy\r\nTemperature      : 39 F (4 C)\r\nDewPoint         : 33 F (1 C)\r\nRelativeHumidity : 80%\r\nPressure         : 29.94 in. Hg (1014 hPa)\r\nStatus           : Success\r\n.Example\r\nPS C:\\&gt; Get-WeatherLocation \"united states\" -city \"Charlotte\" | get-weatherbyproxy | out-gridview -title Weather\r\n\r\nThis command uses a related function called Get-WeatherLocation to find all US locations that have Charlotte in the name and retrieves the weather for each location. Results are displayed using Out-Gridview.\r\n.NOTES\r\nNAME        :  Get-WeatherByProxy\r\nVERSION     :  1.0   \r\nLAST UPDATED:  2\/18\/2015\r\nAUTHOR      :  Jeff Hicks\r\n\r\nLearn more about PowerShell:\r\n<blockquote class=\"wp-embedded-content\" data-secret=\"7zQe85bKxX\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/essential-powershell-resources\/\">Essential PowerShell Learning Resources<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Essential PowerShell Learning Resources&#8221; &#8212; The Lonely Administrator\" src=\"https:\/\/jdhitsolutions.com\/blog\/essential-powershell-resources\/embed\/#?secret=zFd4lUahdt#?secret=7zQe85bKxX\" data-secret=\"7zQe85bKxX\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\r\n\r\n  ****************************************************************\r\n  * DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED *\r\n  * THOROUGHLY IN A LAB ENVIRONMENT. USE AT YOUR OWN RISK.  IF   *\r\n  * YOU DO NOT UNDERSTAND WHAT THIS SCRIPT DOES OR HOW IT WORKS, *\r\n  * DO NOT USE IT OUTSIDE OF A SECURE, TEST SETTING.             *\r\n  ****************************************************************\r\n.LINK\r\nNew-WebServiceProxy \r\n.INPUTS\r\nStrings\r\n.OUTPUTS\r\nCustom object\r\n#&gt;\r\n[cmdletbinding()]\r\nParam(\r\n[Parameter(Position=0,Mandatory,\r\nHelpMessage=\"Enter the name of a city. Preferably one with an airport\",\r\nValueFromPipeline,ValueFromPipelineByPropertyname)]\r\n[ValidateNotNullorEmpty()]\r\n[string[]]$City,\r\n[Parameter(Position=1,ValueFromPipelineByPropertyname)]\r\n[ValidateNotNullorEmpty()]\r\n[string]$Country = \"United States\"\r\n\r\n)\r\n\r\nBegin {\r\n    Write-Verbose -Message \"Starting $($MyInvocation.Mycommand)\"  \r\n    Try {\r\n        #hashtable of parameters to splat to New-WebServiceProxy\r\n        $paramHash = @{\r\n         uri = 'http:\/\/www.webservicex.com\/globalweather.asmx?WSDL'\r\n         ErrorAction = 'Stop'\r\n        }\r\n        Write-Verbose \"Creating web proxy to $($paramHash.uri)\"\r\n        $webproxy = New-WebServiceProxy @paramHash    \r\n    }\r\n    Catch {\r\n        Throw $_\r\n    }\r\n} #begin\r\n\r\nProcess {\r\n    #only process if there is a proxy object\r\n    if ($webproxy) {\r\n      foreach ($location in $city) {\r\n        Write-Verbose \"Getting weather for $location, $country\"\r\n        Try {\r\n            #result is XML so let's make it an object\r\n            [xml]$doc = $webproxy.GetWeather($location,$country)\r\n            \r\n            Write-Debug ($doc.CurrentWeather | out-string)\r\n\r\n            #get the child nodes which will be the properites\r\n            #but omit Status since we don't need it.\r\n            $properties = $doc.CurrentWeather.ChildNodes.name | \r\n            Where {$_ -ne 'Status'} | Select -Unique\r\n            \r\n            #create a custom object and add each property value trimmed\r\n            #of extra spaces\r\n            $propHash = [ordered]@{}\r\n            #there are duplicate node names so we'll join them \r\n            #into a single property\r\n            foreach ($property in $properties) {\r\n                Write-Debug $property\r\n                $value = ($doc.currentWeather | select-xml \"\/\/$property\" | select -expand Node).'#text'.trim() -join \" \"\r\n                $propHash.Add($property,$value)\r\n            }\r\n            Write-Debug ($propHash | out-string)\r\n            #Write the result\r\n            [pscustomobject]$propHash\r\n        } #try xml\r\n        Catch {\r\n            Write-Warning \"Failed to find weather information for $location, $country\"\r\n            Write-Warning $_.exception.message\r\n        } #catch\r\n      } #foreach location\r\n    } #if $weather\r\n} # process\r\n\r\nEnd {\r\n    Write-Verbose -Message \"Ending $($MyInvocation.Mycommand)\"\r\n} #end\r\n\r\n} #end function\r\n\r\n\r\nSet-Alias -Name gwp -Value Get-WeatherByProxy\r\n<\/pre>\n<p>In looking at the XML, there were a few minor issues. One, the Wind node was repeated so I decided to combine the two into a single property. I also noticed that some of the node values had extra spaces. So I trimmed up the values as a I built an ordered hashtable which I then turned into a custom object. The end result is an easy to use tool.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/02\/021915_1502_APowerShell14.png\" alt=\"\" \/><\/p>\n<p>You can even pipe between commands.<\/p>\n<pre><code>get-weatherlocation -city chicago | get-weatherbyproxy | Out-GridView -title \"Chicago\"<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/02\/021915_1502_APowerShell15.png\" alt=\"\" \/><\/p>\n<p>The object properties are all strings which means sorting or filtering is troublesome, but there is some good data here so I guess it is a trade-off.<\/p>\n<p>Now you have several ways to check the weather, assuming you can't simply look out a window. And hopefully you've learned a few new things about PowerShell along the way.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been having some fun this week sharing a few tools for getting weather information and forecasts using PowerShell. To complete the story, today I have one more technique. Using PowerShell, you can query a web service for weather information. In simple terms a web service is like an application you can &#8220;run&#8221; via a&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"New article: A #PowerShell Weather Service","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,8],"tags":[488,534,540,456,206],"class_list":["post-4252","post","type-post","status-publish","format-standard","hentry","category-powershell","category-scripting","tag-invoke-webserviceproxy","tag-powershell","tag-scripting","tag-select-xml","tag-xml"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>A PowerShell Weather Service &#8226; The Lonely Administrator<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/4252\/a-powershell-weather-service\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"A PowerShell Weather Service &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"I&#039;ve been having some fun this week sharing a few tools for getting weather information and forecasts using PowerShell. To complete the story, today I have one more technique. Using PowerShell, you can query a web service for weather information. In simple terms a web service is like an application you can &quot;run&quot; via a...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/4252\/a-powershell-weather-service\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2015-02-19T15:03:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2015-02-19T15:10:20+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/02\/021915_1502_APowerShell1.png\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4252\\\/a-powershell-weather-service\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4252\\\/a-powershell-weather-service\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"A PowerShell Weather Service\",\"datePublished\":\"2015-02-19T15:03:14+00:00\",\"dateModified\":\"2015-02-19T15:10:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4252\\\/a-powershell-weather-service\\\/\"},\"wordCount\":605,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4252\\\/a-powershell-weather-service\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/02\\\/021915_1502_APowerShell1.png\",\"keywords\":[\"Invoke-WebserviceProxy\",\"PowerShell\",\"Scripting\",\"Select-XML\",\"xml\"],\"articleSection\":[\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4252\\\/a-powershell-weather-service\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4252\\\/a-powershell-weather-service\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4252\\\/a-powershell-weather-service\\\/\",\"name\":\"A PowerShell Weather Service &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4252\\\/a-powershell-weather-service\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4252\\\/a-powershell-weather-service\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/02\\\/021915_1502_APowerShell1.png\",\"datePublished\":\"2015-02-19T15:03:14+00:00\",\"dateModified\":\"2015-02-19T15:10:20+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4252\\\/a-powershell-weather-service\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4252\\\/a-powershell-weather-service\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4252\\\/a-powershell-weather-service\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/02\\\/021915_1502_APowerShell1.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/02\\\/021915_1502_APowerShell1.png\",\"width\":624,\"height\":245},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4252\\\/a-powershell-weather-service\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"A PowerShell Weather Service\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"A PowerShell Weather Service &#8226; The Lonely Administrator","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4252\/a-powershell-weather-service\/","og_locale":"en_US","og_type":"article","og_title":"A PowerShell Weather Service &#8226; The Lonely Administrator","og_description":"I've been having some fun this week sharing a few tools for getting weather information and forecasts using PowerShell. To complete the story, today I have one more technique. Using PowerShell, you can query a web service for weather information. In simple terms a web service is like an application you can \"run\" via a...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4252\/a-powershell-weather-service\/","og_site_name":"The Lonely Administrator","article_published_time":"2015-02-19T15:03:14+00:00","article_modified_time":"2015-02-19T15:10:20+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/02\/021915_1502_APowerShell1.png","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4252\/a-powershell-weather-service\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4252\/a-powershell-weather-service\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"A PowerShell Weather Service","datePublished":"2015-02-19T15:03:14+00:00","dateModified":"2015-02-19T15:10:20+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4252\/a-powershell-weather-service\/"},"wordCount":605,"commentCount":0,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4252\/a-powershell-weather-service\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/02\/021915_1502_APowerShell1.png","keywords":["Invoke-WebserviceProxy","PowerShell","Scripting","Select-XML","xml"],"articleSection":["PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4252\/a-powershell-weather-service\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4252\/a-powershell-weather-service\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4252\/a-powershell-weather-service\/","name":"A PowerShell Weather Service &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4252\/a-powershell-weather-service\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4252\/a-powershell-weather-service\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/02\/021915_1502_APowerShell1.png","datePublished":"2015-02-19T15:03:14+00:00","dateModified":"2015-02-19T15:10:20+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4252\/a-powershell-weather-service\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4252\/a-powershell-weather-service\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4252\/a-powershell-weather-service\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/02\/021915_1502_APowerShell1.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/02\/021915_1502_APowerShell1.png","width":624,"height":245},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4252\/a-powershell-weather-service\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"A PowerShell Weather Service"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":4529,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4529\/whats-the-weather\/","url_meta":{"origin":4252,"position":0},"title":"What\u2019s the Weather?","author":"Jeffery Hicks","date":"September 23, 2015","format":false,"excerpt":"I have used a PowerShell module I wrote a while ago to retrieve weather information from Yahoo.com. Yahoo offers a set of web APIs which are free to use, that will provide weather information for a given location. The location is determined by a \"Where On Earth ID\", or woeid.\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"clouds","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/09\/092315_1158_WhatstheWea1.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":2639,"url":"https:\/\/jdhitsolutions.com\/blog\/friday-fun\/2639\/friday-fun-scraping-the-web-with-powershell-v3\/","url_meta":{"origin":4252,"position":1},"title":"Friday Fun: Scraping the Web with PowerShell v3","author":"Jeffery Hicks","date":"December 21, 2012","format":false,"excerpt":"We often think about PowerShell v3 as being a management tool for the cloud. One new PowerShell v3 cmdlet that lends substance to this idea is Invoke-WebRequest. This is a handy for retrieving data from a web site resource. It might be a public web site or something on your\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4222,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4222\/baby-its-cold-outside\/","url_meta":{"origin":4252,"position":2},"title":"Baby, It&#8217;s Cold Outside","author":"Jeffery Hicks","date":"February 16, 2015","format":false,"excerpt":"I don't know about your neck of the woods, but it is downright Arctic here. So I thought I'd polish up my PowerShell function to get weather data. #requires -version 3.0 Function Get-MyWeather { <# .Synopsis Get the weather for a US zip code .Description This command will query the\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"weather","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/02\/weather-300x138.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":579,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/579\/powershell-picasso\/","url_meta":{"origin":4252,"position":3},"title":"PowerShell Picasso","author":"Jeffery Hicks","date":"February 23, 2010","format":false,"excerpt":"You have probably heard the story (or legend) about Pablo Picasso and his napkin drawing. A guy goes up to Picasso in a cafe and asks for an autograph or something. Picasso sketches out something in a minute or so. He turns to the guy and says, \u201cThat will be\u2026","rel":"","context":"In &quot;PowerShell v2.0&quot;","block_context":{"text":"PowerShell v2.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},"img":{"alt_text":"powershell--picasso","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/02\/powershellpicasso_thumb.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":4368,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4368\/friday-fun-get-powershell-user-groups\/","url_meta":{"origin":4252,"position":4},"title":"Friday Fun: Get PowerShell User Groups","author":"Jeffery Hicks","date":"April 10, 2015","format":false,"excerpt":"The other day Don Jones tweeted about find a PowerShell user group. In case you didn't know, just about every user group associated with PowerShell can be found online at http:\/\/powershellgroup.org. This is a terrific resource for finding a user group near you. Of course, Twitter being what it is\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3140,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/3140\/friday-fun-quote-of-the-day-revised\/","url_meta":{"origin":4252,"position":5},"title":"Friday Fun: Quote of the Day Revised","author":"Jeffery Hicks","date":"June 28, 2013","format":false,"excerpt":"This week TrainSignal has been running a contest to celebrate my new PowerShell 3.0 course . All you have to do to win is enter some off-the-wall, silly or non-production use of PowerShell. I've posted a few examples on the TrainSignal blog this week. \u00a0These Friday Fun posts I write\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"talkbubble-v3","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/05\/talkbubble-v3-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4252","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=4252"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4252\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=4252"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=4252"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=4252"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}