Search
Generic filters
Exact matches only
Filter by Custom Post Type

TechSession Webinar: The Top 10 Considerations When Writing #PowerShell Advanced Functions

On Wednesday, September 2nd at 2pm EDT (1pm CDT), I’ll be presenting the September TechSession Webinar for PowerShell.org. The topic for this month's session is: “The Top 10 Considerations When Writing PowerShell Advanced Functions”.

Here’s what you can expect from my presentation:

There are lots of things to consider when writing an advanced function in PowerShell depending on what the function will be designed to accomplish, what operating system and PowerShell versions it will be written for, and who will be using it. During this session, PowerShell MVP Mike F Robbins will walk you through the top 10 items that he takes into consideration along with his thought process when creating advanced functions in PowerShell. We’ll briefly discuss comment based help, parameters, parameter validation, pipeline input, and error handling. This will NOT be a deep dive into any one of these topics as the focus of this session will be on writing advanced functions to maximize code reusability by minimizing static values. Prior experience with PowerShell is recommended.

Registration URL: https://attendee.gotowebinar.com/register/39900545688014338

Who am I?

Mike F Robbins is a Microsoft MVP on Windows PowerShell and a SAPIEN Technologies MVP. He is a co-author of Windows PowerShell TFM 4th Edition and is a contributing author of a chapter in the PowerShell Deep Dives book. Mike has written guest blog articles for the Hey, Scripting Guy! Blog, PowerShell Magazine, and PowerShell.org. He is the winner of the advanced category in the 2013 PowerShell Scripting Games. Mike is also the leader and co-founder of the Mississippi PowerShell User Group. He blogs at mikefrobbins.com and can be found on twitter @mikefrobbins.

µ

Walkthrough: An example of how I write PowerShell functions

A couple of days ago I posted a blog article titled "PowerShell function: Test-ConsoleColor provides a visual demonstration of the foreach scripting construct" and today I thought I would walk you through that function step by step since it's what I consider to be a well written PowerShell function.

It starts out by using the #Requires statement to require at least PowerShell version 3 or it won't run. It also requires that the PowerShell Community Extensions module be installed since it uses a function from that module and continuing without it only leads to errors:

#Requires -Version 3.0 -Modules Pscx

The function is then declared using a Pascal case name that uses an approved verb along with a singular noun. Comment based help is provided just inside the function declaration. This isn't the only location where comment based help can be specified at, but it's my preferred location for it.

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.

µ

PowerShell Tip from the Head Coach of the 2014 Winter Scripting Games: Design for Performance and Efficiency!

There are several concepts that come to mind when discussing the topic of designing your PowerShell commands for performance and efficiency, but in my opinion one of the items at the top of the list is "Filtering Left" which is what I'll be covering in this blog article.

First, let's start out by taking a look at an example of a simple one-liner command that's poorly written from a performance and efficiency standpoint:

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.

µ

PowerShell Tip #3 from the Winner of the Advanced Category in the 2013 Scripting Games

In my previous blog article (PowerShell Tip #2), I left off with the subject of inline help and stated there was a better way. I’m fast-forwarding through lots of concepts and jumping right into “Advanced Functions and Scripts” with this tip because they are where you’ll find the answer to a “better way” to add inline help.

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.

µ

PowerShell Tip #2 from the Winner of the Advanced Category in the 2013 Scripting Games

Tip #2 - Comment (Document) your code!

This is another one of those tips that probably isn't very popular, but regardless of how good you are at writing PowerShell scripts and functions, they're useless if no one else can figure out how to use them. You might be thinking that you're the only one who uses the PowerShell code that you write, but I'm sure that you like to go on vacation just like the rest of us and none of us are going to live forever.

In my tip #1 blog you learned that you need to "Read the Help!". This tip builds on the first one because it allows others to "Read the Help!" for the PowerShell code that you write.

The type of help that you want to provide for your PowerShell functions and scripts is "Comment Based Help". 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.

µ

PowerShell Tip #1 from the Winner of the Advanced Category in the 2013 Scripting Games

In case you haven't heard, the 2014 Winter Scripting Games are just now getting started. Regardless of your skill level with PowerShell, it couldn't be a better time to participate since this is the first time in the history of the scripting games that you'll be able to work as part of a team and receive proactive feedback (before your code is judged) from a team of expert coaches who use PowerShell in the real world on a daily basis. Ultimately, the scripting games make learning PowerShell more interesting and challenging while giving you the opportunity to network with other enthusiasts in the industry.

Now it's time to talk about a PowerShell tip that I wanted to share.

Tip #1 - Read the Help!

While this may not be the most popular tip, believe it or not, it's one of the most important and it's something that's so simple it's often times overlooked. In my opinion, you'll never truly be effective with PowerShell and be able to figure things out for yourself until you learn to read the help.

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.

µ

Introducing the Coaches of the 2014 Winter Scripting Games

A few weeks ago, just before the announcement to start recruiting your team for the 2014 Winter Scripting Games, I was contacted by Don Jones and Richard Siddaway about an opportunity to become the Head Coach for the Winter Scripting Games. I was honored to have been contacted and I'm a firm believer of taking advantage of opportunities when they emerge, especially when they're PowerShell related, so I graciously accepted.

One of my first responsibilities was to recruit a small team of coaches. I immediately went to work before potential coaches committed themselves to participating on teams. We had a huge number of people in the PowerShell community who had volunteered to be a coach and while we would have liked to have selected everyone who volunteered, we only had a specific number of positions to fill. Without further ado, here is the list of the coaches for the 2014 Winter Scripting Games:

Name Twitter
Boe Prox @proxb
Carlo Mancini @sysadm2010
Claus Nielsen @claustn
Emin Atac @p0w3rsh3ll
Jan Egil Ring @JanEgilRing
Jeff Wouters @JeffWouters
Jonathan Medd @jonathanmedd
Lido Paglia @nicemarmot
Matt Hitchcock @hitchysg
Rob Campbell @mjolinor
Rohn Edwards @magicrohn
Sahal Omer @GetExchange
Steve Murawski @StevenMurawski

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.

µ

People Who are Blogging About the 2013 Scripting Games

I'm sure that most people can easily find any of the blogs of the official judges from the 2013 Scripting Games. I recommend reading those blogs whether you're competing in the scripting games or not since there's a wealth of great information contained in them. The best place to find those blogs if you don't know already is the Judges Notes section under the Scripting Games area on PowerShell.org so there's no reason to duplicate them here.

There are also a number of people who are competing in the Scripting Games that are writing blog articles of their own blog sites. A couple of the ones that I'm aware of are listed below and while they're my competition in the advanced class and have links promoting their Scripting Games entries in their blogs (I do the same thing),  I don't mind promoting their blog articles because there's some great information to be found in them. I'm actually glad they provided links to their entries because both of these guys are excellent PowerShell scripters and you could learn a lot from viewing their Scripting Games entries. Ultimately the scripting games is all about the community learning more about using PowerShell best practices in a friendly competition that's just for fun. 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.

µ

Skip to toolbar