Friday, 9 August 2013

Windows PowerShell for Developers #1

A Little Bit About Me (and what I do).

I write software for a living.  I also do it as one of my hobbies, and I have been known to even sell some of the stuff I've written in my spare time.  On the whole I enjoy doing it.  It pays well, it's interesting and it's challenging, unlike many jobs.

Like most occupations, however, it has its tedious stretches, and these generally involve having to do the same things over and over again.  I used to think that it would be nice to automated a lot of the tedious stuff but when I write software I do it on a Windows machine.  Windows can be automated, but up until recently most tasks on it have been point-and-click.  Automating repetitive tasks often meant automating pointing and clicking.

None more so than with Visual Studio, where all the functionality is available at the end of a mouse button.  In recent editions there have been such new features as macros to help with the housekeeping, but these really haven't caught on, not least because of the seemingly Byzantine object models used to manage the design-time environment and their old-fashioned dialect of Visual Basic.  Macros have been dropped from  Visual Studio 2012 and all subsequent editions, so people like me looking for a quick-and-dirty fix for our repetitive task issues are going to have to look elsewhere.

Enter PowerShell

Thankfully, I think that hunt is over.  We have an ideal tool installed by default on every version of Windows from Windows 7 upwards, and by intention on a fair few computers running earlier versions.  That tool is Windows PowerShell, a hideously powerful scripting language designed expressly for the automation of common Windows tasks. Like most scripting languages, it comes with its own run time environment (which is nothing more than a glorified Windows command prompt).  It doesn't need to be compiled and so can be invoked interactively, and is supported by an extensive gamut of predefined commands for performing common systems housekeeping tasks.

PowerShell is a systems administrator's tool first and foremost, but that doesn't mean it won't lend itself to making life more pleasant for us developers.  As part of a project to build a systems integration process, I've been teaching myself PowerShell to automate it and I've found it an interesting and fun experience.  Suddenly, tasks that I thought were only able to be automated by the Gods of Scripting became fairly straightforward.  I'd like to share these experiences with you in the hope that you'll also find them interesting, fun and hopefully, very helpful to boot.

So, in the next installment of this blog, we'll take a look at how tasks used to be automated in Windows, and how this related to everyday development work.

No comments:

Post a Comment