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. Fortunately, there are APIs to get that information as well. All of this is very easy to use with the Invoke-Webrequest cmdlet. The result is an XML document, which takes a little bit of work to parse out.
My module has a command to get a woeid:
Once you know that you can get weather information.
Or more detailed information:
You can even pipe one command to the other.
The cmdlets have complete help but instead of comment based help, I am using a MAML-based XML file. I created the file with an early version of SAPIEN’s PowerShell Help Writer.
Because I like to think the module contains some good examples of using Invoke-Webrequest and working with XML documents, I have published the module to Github. I hope you’ll give it a try and let me know what you think. At some point I might even publish it to the Microsoft PowerShell Gallery.
Last week I gave two presentations at the European edition of the PowerShell Summit held in beautiful Stockholm, Sweden. If you weren’t able to attend, you can still enjoy the sessions because everything was recorded. Session recordings for the entire conference can be found on PowerShell.org’s YouTube channel.
I thought I would post something here about my sessions including my demos and slides. One of my talks was on customizing the PowerShell ISE. I spend a lot of time in the ISE and have developed a lot of tricks and shortcuts to save myself time and frustration. My presentation explained how to create your own shortcuts and demonstrated a lot of my tips and tricks.
My other presentation was about techniques and tips around logging in PowerShell. We often want to include a logging mechanism into our scripts and modules and there are a number of techniques you can use. Additionally, there may be a need for logging an entire PowerShell session. I talked about ways to accomplish that including a peak at some new PowerShell v5 features.
Hopefully the videos and material will be of some use to you, although I have to tell you that the real benefit of attending the Summit is the interaction with other attendees and speakers. It is the exchange of information between sessions that is extremely valuable and impossible to capture unless you attend.
Seats for the next North American event in Bellevue, WA will be limited so keep an eye on the calendar and act fast when tickets go on sale.
Last year I posted an article and a set of PowerShell functions to make it easier to format values. For some reason, I decided to revisit the functions and ended up revising and extending them. I modified Format-Value so that you can format a number as a currency or a number.
Format-Value help (Image Credit: Jeff Hicks)
The function is assuming you will pipe values to it.
Format-Value examples (Image Credit: Jeff Hicks)
I also wrote a new function called Format-String.
Format-String help (Image Credit: Jeff Hicks)
The nice thing is that you can apply as many or all of the formatting transformations as you want.
Format-String examples (Image Credit: Jeff Hicks)
The Replace option works by taking a hashtable and replacing each matching key with its value.
Using the Replace parameter in Format-String (Image Credit: Jeff Hicks)
One task that comes to mind where Format-String might come in handy is in building passwords.
The function contains the following aliases:
fp = Format-Percent
fv = Format-Value
fs = Format-String
I’m also trying something different, at least for me. Instead of posting the code here, I’ve started to use GitHub since that seems to be what all the cool kids are doing. You can find the FormatFunctions module at https://github.com/jdhitsolutions/FormatFunctions. This should also make it easier for me to post revisions, address bugs and make it easier for you to take my code and run with it. You’re still welcome to post comments here, but use GitHub for anything specific to the PowerShell code.