Learn about Windows PowerShell
Summary: The Scripting Wife provides tips and hints for the 2012 Scripting Games Beginner Event 6.
These past couple of days, Ed has been tied up, so I have free reign of the house. This means I have a lot of projects I want to complete. For some reason, when he is around, it seems like he often gets under foot–a situation especially problematic when I have a detailed game plan. Anyway, this means that I am up early so I can maximize my time. I completed Beginner Event 6, and I want to provide you with some good hints.
First of all, this is the most difficult event (at least for me) so far of the 2012 Scripting Games (on the beginner track). This means that you should take your time, and it also means that you will probably need to do some research before you write your script.
The first thing I needed to do was to find what property would tell me when the server would boot. I used the Get-WMIObject cmdlet and piped the results from the WMI class the boss told me to use to Get-Member. It did not take very long at all to find the property I needed. I then needed to change the format of that date value.
One of the things you will need to know is how to convert a WMI date into something more usable. I looked at all of the blogs about dates listed in the 2012 Scripting Games Study Guide, and I did not really find what I was wanted. But I then did a search (by using the Search This Blog feature on the Hey, Scripting Guy! Blog), and I was able to find exactly the information that I needed. The exact search words I used were wmi date, and it returned several hits. The one I needed was called Manipulating Dates Returned by Windows Management Instrumentation (WMI).
The next thing I had to look up was was how to compute the amount of time between two dates. I found this information in the Date section of the 2011 Scripting Games Study Guide...come to find out, it was a Scripting Wife blog! Oh yeah, I remember that now.
The last part, formatting the output, required me to mess around with substituting values for parameters. This can get a little tricky, but there are lots of ways to get the same result.
Hope this helps. Remember, you have until 12:01 AM on April 16, 2012 (-8 Pacific time) (or basically midnight on the night of April 15, 2012) to submit your entry. This one would definitely be a good one to set aside and come back to later. Good luck, and happy scripting.
I found this one really difficult too. Found the objects I needed pretty easily and also found a scriptmethod that sounded like just what I needed but had no idea how to use it!
Read your post and half an hour later I have a working script put together and it looks great!
Thanks for the advice @scriptingwife!
The whole purpose of me entering the games is to encourage others to try their hand at scripting. PowerShell is such an awesome tool and I get so excited to see someone embrace it. Thanks for letting me know I helped. Good luck.
It's funny. I just read how to do this in Don Jones' "Learn Windows Powershell in a Month of Lunches"