Mastodon

Sunday 4 July 2010

Getting started with PowerShell

So what is it about PowerShell that interests me? Well as someone who started out in the server admin world with a hand full of Linux boxes, albeit in a fairly amateur capacity, I've always naturally been comfortable working at a command prompt. In a Windows world though it's always seemed that to automate anything via scripting there are so many ways to do things, depending on what you want to achieve, with none of them really covering all the bases. Traditional batchscripts, vbscript, wmi, adsi, no one scripting technology really covers everything, and you end up using a collection of things, with one method calling another method etc, since each method lends itself so well to some things more than others.

For instance, I in one script I wrote, you've got a batchscript handling the basic flow and logic of the script, that then calls a few of the GNU ported linux functions like grep, tail, wget etc, and uses vbscript to handle sending e-mail using the JMail component, and at one point calling WMI functions as well!

When I first heard about PowerShell it sounded like finally there might be a language I could invest some time into learning, safe in the knowledge that it could cover what ever I was trying to achieve. Of course like many things there was the question, 'is this too good to be true?', and at first it was. After all, it's great that you can control Windows 2008, Exchange 2007 and SQL Server 2008 etc via PowerShell, but when you're still predominantly using 2003, 2003 and 2005, that's not a lot of use. Now of course things have changed, and it's worth taking the time to learn the language, so that's what I'm determined to do. I think my first challenge will be to get my head about the basics of the language itself, and how the flow control etc is supposed to work, and then work on re-writing many of my more commonly used scripts to use PowerShell instead.

I'll keep you posted on how I get on.

No comments:

Post a Comment