Impractical One-liner Challenge #2

Posted on

It’s back, your favorite Friday PowerShell diversion!

The get-date command has a useful method called GetDateTimeFormats() that lists all of the available date-time formats available on your system, suitable for you to find just the right date format to fit your needs.  However, actually using the output can be difficult, as you must use the following syntax, (Get-Date).GetDateTimeFormats()[<index>] and picking the right one from a huge non-numbered list can be challenging.

Your Mission

Display all of the dateTime formats available, along with the index position of each in a graphical GUI user interface for the user to pick the format they desire, then use that selection to display a tip to the user on how to get that particular format.


  • Try to avoid using Semicolons.  If you have to use one, explain it.
  • You are encourage to use backticks and PowerShell next-line detection (brackets, pipes) to wrap your code in to a readable one-liner
  • Interpret GUI and ‘display a tip’ however you like
  • No prizes, no whining!

SCCM 2012 Log File Quick Reference Chart

Posted on

Jumping back into the SCCM Saddle, I noticed that I could really benefit from a printable SCCM reference guide.  I decided to whip one up, using the data from the Technet page.

Print up this full-sized .png or download the PDF Below.

Printable SCCM 2012 Log File Chart and Reference Guide
Printable SCCM 2012 Log File Chart and Reference Guide

SCCM 2012 Logs Chart

Walkthrough Part two: Advanced Parsing with ConvertFrom-String

Posted on Updated on

In our previous post we used the tried and true old school method to convert data from the console or logs into a PowerShell object.  It works but it isn’t very much fun and by and large you have to write a lot of code to do it.

I’ve dug under the covers, thanks to these excellent resources (at the bottom of this post!) and have now come up with a method to parse files using PowerShell Version 5’s awesomely powerful new ConvertFrom-String cmdlet.  This tool is based on FlashExtract, which is a Microsoft Labs creation that originally showed up in Excel under the FlashFill and FlashConvert tools, which let you highlight some sample data and watch as a machine learning creates regex string extraction tools for you.  Automatically.

I’m not sure if is cool or if it is scary.  It’s definitely cool at least!

This new approach drops down from more than 60 lines of code to only 13 to parse the data.  But the craziest thing about is how the code looks and works.

Machine learning will take our jobs

Will it? Maybe…probably. Previously you needed Exchange Admins to monitor all of an org’s exchange servers, and infrastructure admins to watch over the datacenter, plus guys to swap tapes, make custom internal apps and things like that. Now you can do all of that through AWS or Azure, so presumably at least one guy is looking for a job now. Probably the one who tended the printers and tape drives. Most of the apps we’d make internally have now found a ‘good-enough’ alternative online with SaaS. My personal plan is to try to be the guy who automates the last mile and glues all of the systems together, so hopefully I’ll have a job as long as possible.
Read the rest of this entry »

Walkthrough – Parsing log or console output with PowerShell

Posted on Updated on

As I go from project to project, inevitably a task like this one is presented to me, simply because people know they could spend hours and hours doing it themselves but know that surely there is a way to do it quickly.

In this post I’ll walk you through a real world example of how to parse the output of a non-PowerShell command and convert it into PowerShell objects we can work with to export reports, run SQL queries, or to do literally anything under the sun.

If you’ve ever needed to parse log or batch file command output and have slaved at it, hopefully this approach makes things a little easier for you.

This is part of a two-part series,  this one is focused on the traditional, tried-and-true method of parsing output.  The next part will be all about using Convert-FromString to parse input instead, once I understand how to use this powerful new addition to PowerShell in version 5.0.

Read the rest of this entry »

Achievement Unlocked – Microsoft MVP for 2015!

Posted on Updated on

Dear Stephen Owen,  Congratulations! We are pleased to present you with the 2015 Microsoft® MVP Award! This award is given to exceptional technical community leaders who actively share their high quality, real world expertise with others. We appreciate your outstanding contributions in PowerShell technical communities during the past year.  Also in this email: About your MVP Award Gift How to claim your award benefits Your MVP Identification Number MVP Award Program Code of Conduct The Microsoft MVP Award provides us the unique opportunity to celebrate and honor your significant contributions and say "Thank you for your technical leadership."

Wow, talk about feeling blown away.  Back in September I received an e-mail stating that I’d been nominated to become an MVP, and since that moment I’ve felt that I’ve been walking on air.

I had a few career goals over my lifetime, from becoming a consultant and earning my MCSE, to eventually becoming a technical writer and trainer, and possibly even being as bold as to strive to become an MVP.  I never in my wildest dreams thought that it might happen to me!
Read the rest of this entry »

My Site – 2014 in review

Posted on

The stats helper monkeys prepared a 2014 annual report for this blog.

Here’s an excerpt:

The Louvre Museum has 8.5 million visitors per year. This blog was viewed about 76,000 times in 2014. If it were an exhibit at the Louvre Museum, it would take about 3 days for that many people to see it.

Click here to see the complete report.

Unholy Matrimony – wGet and PowerShell together

Posted on Updated on

XML has been around for a LONG time. But just like working with HTML, it still kind of stinks. If you want to reach into a file and pull out values within certain tags, you’d better become a pro with Xpath or be prepared to create some REALLY ugly Regex. For instance, if we wanted to grab the values within the tag we care about for this blog post, the regex would be this simple little number.


You know what they say about using regex…


Fortunately for us, PowerShell makes it very easy to work with XML and pull out properties, and makes it super easy to do so if you take advantage of the built-in .net System.Xml.XmlDocument object type to help you parse it’s values.

For this example, I wanted to make a full backup of my family WordPress Photo site, but there was no easy way to download all of the photos from my blog posts, which is a necessity to transfer my content to another provider, or at least to maintain my own copy of all of my work. (Note to engineers, it would be totally sweet to have the option to download my entire blog in one nice little .zip!). So if, you’re curious about how to backup your WordPress blog including all media, read further!

Read the rest of this entry »