«

Jul 07

Whats in your Toolbox

Source Control

As admins we just like to get things done. Would you disagree? However, as we get things done we move on with little care where we stored the script or items we used to complete the task. We chalk up another win for PowerShell helping us quickly, with precision, to get stuff done. Hooray PowerShell! Now on to the next task. Now it’s a month later and a similar case comes up. We remember we solved this once already. Great, let me go get that script and use it again. For some of us this is where our frustration begins. Sure, you have a folder where you store all your scripts and If you’re really good you have a naming standard you follow but once you get there you need to find it, pull it up in your editor and remember what you did. What was maybe thought to be a small task turns into a bit bigger endeavor.

Two things can help us here. The first is writing tools and not just scripts. The tools or cmdlets allow us to piece together the scripts and in some ways make the scripts more understandable when we have to go through them again. As we write these tools the Second helpful item comes into play–Source Control. Source control will help version our tools, eliminate multiple copies of similar cmdlets, and make is easier to share a common set of tools just to name a few of the benefits. Sound good? Sure it does! Wait, where will the time to do this come from?

This will be a process, and like most processes, it will take some time to get everything into source control. The way I started, was any new tool I created I put in source control. Then as I updated or changed a current script or tool I moved it to my source control. Over time more and more will get into your source control and the things that don’t are most likely stale or onetime use cases that don’t need to be in source control.

As we source control these tools we can then start building our module(s). Once in source control this is supper simple. Here is the psm1 for one of my modules:

 

The folder for my module has a sub folder named scripts. This folder contains all the cmdlets that I write. This psm1 module definition file gets all the files that end in ps1. The reason behind this is as I add new cmdlets to my source control the module import will automatically pick it up. All I have to do is put the tool in my source control. Re-import my module and my new cmdlet is available for me to use. Simple.

Functions I use

 

My Profile

Reference

Profile Tips and tricks: http://theevolvingadmin.blogspot.com/2014/10/powershell-profile-tips-tricks.html

 

1 ping

  1. PhillyPoSH 07/07/2015 meeting summary and presentation materials » PowerShell.org

    […] scripts and presentation are available at our GitHub site. TJ Turner‘s presentation “What’s in your Toolbox” is available at his blog. A recording of this meeting has been posted to our YouTube […]

Leave a Reply