The Practice event started on the first of january and the scenario was offered to us through a zip file that contained two files :

  • A pdf wit the winter scripting games 2014 players guide
  • The event itself.

The scenario has been written by MVP Richard Sidaway and was entitled  : “Server  Inventory”.

I am not going to copy/paste the scenario here, but basically, it asked us to scan a specefic set of ip’s, verify if the IP’s are used, if not, write does available IP’s down in a file, and for the ones available, gater the computername of them.

With that return, we needed to do a specefic computer inventory :OS version, SP pack installed, last software update installed, what type of application  is running on the server (SQL, Sharepoint, Exchange etc..).

The results returned should be (when possible) transformed into a graph, and then exported to an HTML file.

An optional step is to export the graphs directly into a powershell presentation.

I) Dividing the work:

So, in my opinion, this was probably the most “complicated” thing or lets say the “newest thing” that we had to do here : Diving the work “equally” between the 6 different members of the team. The event was eventually a bit “light” for 6 members, but we stilled managed to divide consequently and I tried to cut it in a way that each one of us could have something interesting to script.

We have identified 3 main sections in this scenario :

  • The IP Scan
  • The Server Inventory
  • The exports

Each section has been attributed to two team members and we organized a new date & time to do another google hangeout.

Since we where from 4 different timezones, it was not easy to find a time where everybody could be present, but  eventually we managed to find one 🙂

Google hangeout became our “Hangeout” (Google found the perfect name for that tool there  ;)) and we had a few meetings on there with the whole team.

The first one to share the work. We decided the functions that will need to be written. What type of output they need to give, and what the next function needs as input. (This was done before the meeting, and basically everybody agreed with the division that has been made).

We shared some scripts written on different projects, and some links concerning different subjets that one or another had in their favorites in order to avoid us to lose to much time searching the internet for “the” blog that will bring us the solution.

II) The technical aspects:

Will talk shortly about the two first parts  ( Ip scan and Gather information) since I have mainly worked on the export part (HTML and PowerPoint).

But, of course I am pretty curious and I looked into the code that has been written by my fellow mates, and I must say, that reading code, is most probably te best way to learn new methods.

1 ) Ip scan:

The ip scan has been handled by Dexter and Allister. I think they have done a very good job, and their functions are really fast !


What was pretty cool here I think, they used very strong parameter validation in order to be sure to validate that the inputs are IP adresses.

as for instance this section that covers the parameter validation from the IP address range input:

They used a lot of access to dotnet class, such as this call to to resolve the machines hostname.


2) Gater server information:

What was asked here, was to retrieve a lot of information from the different servers / IP’s that would have been identified in section 1. This is pretty much a routine task if you have participated to the scripting games before 😉

Of course, this information can be retrieved very easily with WMI. François-Wavier (The lazy Win admin) and Guido wrote that part of the script and did great good job! They gave for example the possibilty to choose an alternante protocol :

They also did some very strong parameter validation and offered directly the possiblity to run the script with alternante credentials by integrating the following code:


also every set of data was possible to get retrieved individually from each other by calling each parameter with “switch”



Now lets look into the export part.

3) Exporting the data:

a)The graphics

We basically divided the export part into two sub parts : Generating the graphic, and exporting the data + the graphic.

Benjamin did a great job on generating beautifull exports like the one below with the function he build :


Chart generation example

Chart export example


I have been focusing on the export parts. The HTML part was pretty simple, especially since we used the “-fragment” parameter of the “ConvertTo-HTML.

Actually, it became very easy once I read this super article from the  “powerShell Deep Dives” book. There was an article about html export and it seemed to be tailored for us! (I must say, that in general, this book is really good !)

The article has been written by “Jonathan Medd” , he is part of one of the Scripting games “coaches” and you can visit his blog here.

The article basically indicated how to use the -fragment parameter of the “ExportTo-Html” cmdlet and how to add an image into the export ; Perfect ! That’s exactly what we needed !

Benny has a lot of experience in generating these kind of reports, and came with the idea to use a function that would actually transform the graph into “bytes” version, and intégrated directly in te script. This means that the image file of te chart actually never needs to be saved on the file system. That’s great !

This is what we came up with.
At the end, the HTML export section looked like this:

($ExportPath would of course contain the date and time of when the file was generated  followed by the .html extension).

And this is what the HTML export looked like after Benny re-aranged the CSS with his crazy “gandalfy” CSS little fingers 😉


HTML export - POSH Monks - Winter Scripting Games 2014

And the data section here :

POSH Monks - Winter Scripting games 2014 -  Practice Event


It looks good doesn’t it ? 😉


b) The other exports sections: CSV and Powerpoint.


The scenario asked for HTML, CSV, and PowerPoint exports. HTML we got it covered up here, and CSV, was actually the first one I wrote since it was so simple to that with the integrated cmdlet in powershell

But exporting to PowerPoint ?!! I have written in the past a script that would generate automatically the documentation for a script by reading its comment based help section and exporting it to a predefined word template.(Maybe I should think of blogging about that scriptone day…) I used com objects for that.

So, I knew I was looking for Powerpoint exports with COM objects.

And here, i stumbled in a few problems:

  • The first one was concerning the fact that I couldn’t find anything like asked in the scenario that could fullfill our needs.
  • The second one, is that either the documentation of the COM objects are not so well written (FYI: English is also not my mother language), or COM objects is simply just not that easy to understand.

I would say both !!

Anyways, I managed to swim through this event, and learned a LOT on that topic. I will not post any code concerning the PowerPoint export part since I am planning to blog about it soon.

Ineed, the lack of infos available on the internet (or at least my searching results where not concluding at all!) gave me the idea to write something that could explain a bit how theses COM objects work.

In the mean time, find here what our powerpoint export looked like 😉



It is pretty basic I agree. (I am not really an artist as you can see ;)) But this is generated automatically, and ready to be used for a presentation 🙂


III) The biggest learning point : Putting everyting together.

Dividing a script in 6 parts, let them all be written by 6 different (amazing !) scripters, and then put everything together in one and unique script is something, that none of us had done before.

I have worked on projects where several scripters would each of them write a script that would do certain actions to a system (in my case SCCM, Active Directory, CSV files). But our scripts were dependant on the results that the scripts would have on the system.(EG: Computer object in OU, Collection present in SCCM etc..) But not on each other function or script.

Here, it was a hole new experience since we wanted to have 1 script, that could be called very easil, with only a few arguments. I personally think that it would not have been that of a problem if this task was done alone. But here we had to face different scripters, different time zones (4!!) different scripting styles.

We tried to organise, before even starting scripting, the functions that needed to be written, and what kind of export they needed to have as input & output. But, even with that, it wasn’t so easy.

So putting the wole script together didn’t worked out as expect. We deceided to upload the three different sections as seperate scripts.  After all, the scenario mentionned the fact that everything should be set all into the same script 😉

Anyways, I really think that working as a team for the winter scripting games is a great idea in condition that there is enough work to share between 6 team members of course ! 😉

Well, that’s it for this review. Now, it is time to Attack the second (the first ?) event  : “Pairs” written by “the” PowerShell legend himself : “Ed Wilson” 🙂

Have fun ! Proost ![/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]

By | 2016-10-19T21:00:18+00:00 January 19th, 2014|PowerShell, Scripting Games|4 Comments

About the Author:

Stéphane is a dynamic and passionate Cloud and datacenter Microsoft MVP since. He is the founder of the Basel PowerShell user Group (BPUG), the co-founder of the French Speaking PowerShell UserGroup (FRPSUG), author, blogger, and received the community award "PowerShell Hero" from Stéphane has implemented microsoft infrastructure solutions in various countries of Europe and is currently working in Basel / Switzerland. Stéphane help his clients to reduce their global infrastructure costs by implementing Microsft infrastructure solutions by combining great products such as System Center, Windows Server, with heavy automation using Windows PowerShell. Stéphane loves languages, Belgium beer, French cheese and French Wine. If any of these topics are of your interest, don't hesitate to come and say hi.


  1. DexterPOSH January 20, 2014 at 8:38 am - Reply

    Hello Sir !
    Well written…I think it sums up all our efforts 🙂

  2. Stephane January 19, 2014 at 11:33 pm - Reply

    Thanks FX !

    (I edited and corrected the typo. thx !)

  3. Francois-xavier cat January 19, 2014 at 11:16 pm - Reply

    Great article Stephane!

    Typo: It’s called Splatting not Splitting 🙂

    • Chris July 29, 2014 at 3:12 am - Reply

      This was an awesome tip piderovd to me by my good friend Jason Walker, MS PFE. We had a scripting event that used this method as a means to output data to the clipboard. Thanks for highlighting this Mike and sharing with the community, keep up the great work!

Leave a Reply

%d bloggers like this: