Generic filters
Exact matches only
Filter by Custom Post Type

Using PowerShell Parameter Validation to Make Your Day Easier

Feb 4, 2014

A number of entries in the Winter Scripting Games use parameter validation, but some that I have seen may not be using it correctly or to its full potential.

Writing functions or scripts require a variety of parameters which have different requirements based on a number of items. It could require a collection, objects of a certain type or even a certain range of items that it should only accept.

The idea of parameter validation is that you can specify specific checks on a parameter that is being used on a function or script. If the value or collection that is passed to the parameter doesn’t meet the specified requirements, a terminating error is thrown and the execution of the code halts and gives you an error stating (usually readable) the reason for the halt. This is very powerful and allows you to have much tighter control over the input that is going into the function. You don’t want to have your script go crazy halfway into the code execution because the values sent to the parameter were completely off of the wall.

Click here to be redirected to the original post of this article on the author’s blog site where you can read the remainder of the article.

Winter Scripting Games 2014 Tip #2: Use #Requires to let PowerShell do the work for you

Jan 20, 2014

In Version 2 of PowerShell, you had the ability to use #Requires –Version 2.0 to ensure that your scripts/functions would only run at a specified PowerShell version to prevent folks running an older version from wondering why things weren't working that well.

In this article, I will show you a couple of new additions to the #Requires statement that will make your life easier when writing functions that require specific pre-requisites rather than coding your own methods

Click here to be redirected to the original post of this article on the author’s blog site where you can read the remainder of the article..

Winter Scripting Games 2014 Tip #1: Avoid the aliases

Jan 16, 2014

Having been a judge for the previous 2 Scripting Game competitions as well as competing in the 2 before that, I have seen my share of scripts submitted that didn't quite meet the cut of what I felt were the best scripts. It doesn't mean that they wouldn't work out in the real world in a production environment (Ok, some wouldn't :)), but some were just really hard to read or others were doing things that I wouldn't consider to be a good practice. The first of several articles that I will be doing will start out with the use of aliases in scripts and why this is not necessarily a good idea.

Click here to be redirected to the original post of this article on the author’s blog site where you can read the remainder of the article.

Working with the WSUS API and the SUSDB Database using PowerShell

Tthe WSUS API can be used to perform a multitude of WSUS tasks from approving patches, removing clients to creating automatic approval rules to many other things. By diving deeper into the API reveals that we can also find out the name of the SQL server (if using a remote SQL database server) that the SUSDB database is residing on. Beyond that, we can actually perform queries to the database (using TSQL) or perform tasks against the database itself.

I've written a couple of articles hat focus on making the database connection via the WSUS API and preform a simple query and then following up on that by performing some database maintenance by re-indexing and updating the statistics on the database tables.

Use the WSUS API and PowerShell to query the SUSDB Database

Using the WSUS API and PowerShell to Perform Maintenance on the SUSDB Database

Scripting Games 2013: Event 6 Notes

Jun 9, 2013

We have finally hit the final event of the 2013 Scripting Games! The past 6 weeks have given us many amazing scripts and some that were in need of extra work. Regardless, for those of you who have finished all 6 scripts in your respective, I say Congratulations! You have hit the finish line sprinting hard to the end! Now you can sit back and know that you made it and have learned (hopefully) some great things along the way. Remember, not only have you learned some new techniques, but also the techniques that you have used have taught others how to write better scripts!

Check out the rest of my notes on my blog here!

Scripting Games 2013: Event 5 Notes

Jun 3, 2013

With week 5 in the books, I can see that everyone just continues to grow and show some great submissions. Of course, nothing is perfect and can always show areas of improvement, but trust me, you are all doing an excellent job!

I was hoping to have this article completed prior to now, but between a flight to Tech Ed and forgetting my power cord for the laptop, I am just now getting this accomplished. Better late than never :).

With that, head over to my blog to check out my notes on Event 5 here.

Scripting Games 2013: Event 4 Notes

May 23, 2013

It is all downhill from here folks! Event 4 is in the books and we only have 2 more to go! Everyone has been doing an outstanding job with their submissions and it is becoming clear that people are learning new things and showing some great techniques with their code.

Of course, this doesn't mean that there isn't room for improvement with some submissions to make them even better or just some simple mistakes that can be cleaned up to make average submissions into amazing submissions. With that, its time to dive into my notes… You can check out the rest of this article here.

Scripting Games 2013: Event 3 Notes

May 15, 2013

Wow, it is hard to believe that we are now halfway through the Scripting Games! As the events have progressed, I have seen a lot of improvement with the techniques as well as seeing new techniques that continue to impress me. On the flip side, I have seen some mistakes or assumptions when coding that cause a potential 5 star script to be a 2 or 3 star script. The best part about all of this is that we are all (yes, even the judges) learning new things that can only help to improve everyone’s scripting knowledge. Check out the rest of the article here.

Scripting Games 2013: Event 2 Notes

May 12, 2013

I spent some time last week and this weekend to compile a list of notes of what I have seen with the Event 2 submissions that could show improvement. I touched up on some items with my previous article where I picked out some submissions that I liked and didn't quite like but wanted to touch on a few more things. Some of this feels like a repeat of last week and even last years games, but that is Ok. This is all about learning and as long as everyone takes what all of the judges have been writing about, then there will be nothing but great improvements during the course of the games. Click here to go to continue reading this article.

Scripting Games 2013: Event 2 ‘Favorite’ and ‘Not So Favorite’

May 8, 2013

Event 2 is in the books and with that, it is time to take a look at all of the scripts submitted and make the difficult decisions as to which ones I liked and which ones I didn't quite like.  Just because a script landed on my ‘Not so Favorite’ list doesn't mean it was terrible. It was just that I felt that there were some things here and there that could have been looked at a little differently. In fact, the amount of submissions that were great really made my decisions much for difficult. Everyone has really shown just how much knowledge is out there and how there are many different approaches to a single problem!

Check out my picks here.

Skip to toolbar