Endjin - Home

An Omega Geek’s Guide to Learning PowerShell

by Howard van Rooijen

In the last 12 months we’ve been doing quite a lot of Application Lifecycle Management (ALM) projects helping teams setup Continuous Delivery processes. One of the tenets of Continuous Delivery is “Automate Everything” – which has been a core part of my “work smarter, not harder” ethic for a number of years. The technology that we’ve been using to do this work is one of the hidden gems of the Microsoft Platform – PowerShell. It amazed me that a technology that is over 6 years old still doesn’t seem to have mass adoption within the Microsoft Development Community. While the Alpha Geeks are frothing at the mouth over new tech such as Node / HTML 5 / WinRT, I really hope that more Omega Geeks will do themselves a great favour and start to learn PowerShell.

I’ve spent more of the last year working inside PowerGUI than Visual Studio and I’ve tried hard to take a few of our customers on the learning journey too. I’m very pleased that after doing a quick brown bag session about PowerShell and knocking up a sample framework that one of the DevOps folks took it and ran with it – automating the provisioning of their internal development, test and production environments – from a series of thick word documents that took over 2 man days to work through (and were also horrifically prone to human error) to a series of PowerShell scripts that could automatically provision an environment within a couple of hours.

Thankfully there are a myriad of resources to help you learn PowerShell here are a select that I’ve found very useful:

Free Guides

If you really want to get your head around what comes out of the box in PowerShell 2.0 (which is installed by default on Windows 7 and Windows Server 2008) a great place to start is Jonathan Medd’sPowerShell 2 – One Cmdlet at a Time – which does exactly what it says on the tin – it lists every cmdlet (think function) and tells you what it does and how to use it.

One of the least known and most powerful features in PowerShell is remoting – the ability to execute PowerShell scripts, in context on a remote machine. This opens so many doors from a DevOps perspective. On the downside – because remoting requires you to deal with networks and security – it can be a bit painful to get up and running with and another indispensible guide is Ravikanth Chaganti’s – Layman’s Guide to PowerShell 2.0 remoting – to tell the truth – I felt bad reading this free guide – the amount of real world knowledge and blood, sweat and tears problem solving is of such a high quality that it really shouldn’t be a free ebook.

Books

The two free guides really wet my appetite and I wanted more – both depth and breadth and I found this in abundance in Bruce Payette’sPowerShell in Action 2nd Edition – if you want a holistic view of the platform – it’s a great start. If you want a more practical guide to how to use PowerShell there are two other great resources – first is Don Jones and his book Learn Windows PowerShell in a Month of Lunches. Don is a bit of a star he’s very active not only on his twitter account – but he’s also produced a seriously large number of accompanying screencasts, freely available on YouTube. The second is Lee Holmes (who’s been on the PowerShell team from the start), his book The PowerShell Cookbook is a wonderful resource – brimming with Problem –> Solution recipes; if you’re getting started with PowerShell these are the type of problems you are going to hit straight away and such The PowerShell Cookbook should be your first port of call. The latest PowerShell book I’ve been reading is PowerShell and WMI by Richard Siddaway which is a little more advanced and hard-core – but useful for those of us who want to interact with Windows Machines at a lower level.

Blogs & People

As always the first place for a Microsoft Technology is the Official Microsoft PowerShell Blog. Next would be the man behind PowerShell, Microsoft Distinguished Engineer and  Lead Architect for the Windows Server Division – Jeffery Snover, his enthusiasm for PowerShell and being more productive with automation is utterly infectious – he’s a really great speaker and I would highly recommend watching his talks (listed below). After Jeffery the next stop is Lee Holmes’ blog. When you get stuck and start searching for help – chances are you’ll land on Joel Bennett’s Huddled Masses blog – lots of great pragmatic content to be devoured there. Another great resource is the PowerShell Community Site.

Web Casts

If you don’t have time to read books luckily Microsoft have put a lot of effort promoting PowerShell at their various conferences and via Channel9. I can’t recommend these talks highly enough – the topics are wide and varied – from using PowerShell to manage servers, to using PowerShell to create a management API over your applications – each of the talk shows how flexible PowerShell is and how productive you can be with it.

Channel 9

PDC 2008

PDC 2009

Tech-Ed 2010

Build 2011

Tech-Ed 2011

Writing testable scripts

One of the most immature aspects of the PowerShell platform is writing tests for scripts – I’ve tried many of the frameworks that are out there – each has it’s own strengths and weaknesses – but the framework I’ve been using (with some success) of late is Pester – a BDD style framework for PowerShell, you can grab the code from the official GitHub Repository.

Tooling

Lastly a word on tooling – even though Windows comes with PowerShell ISE (Integrated Scripting Environment) – I’ve found PowerGui to be a much nicer environment to work in – the debugging support (which you will need) is far superior to ISE.

Remember: work smarter, not harder!

@HowardvRooijen

About the author

Howard spent 10 years as a technology consultant helping some of the UK's best known organisations work smarter, before founding endjin in 2010. He's a Microsoft Accelerator Mentor, and a Microsoft Azure MVP. You can follow him on Twitter via @HowardvRooijen