November 29, 2010
I’m primarily a Linux admin, but I’m a pragmatic admin, so I use what’s best, and it just so happens that Windows is better than Linux for me in some cases (mostly centralized authentication, but there are also some softwares out there that only run on Windows). The point is that I have a heterogeneous network, and I can’t afford to have some of my machine be “second class” citizens.
I’ve also scripted in bash for years now, sometimes to the point of absurdity. I’m hesitant to switch away, just because I have so much braintrust dedicated to bash, but alas, bash doesn’t run natively on Windows without some work, and I’m generally of the opinion that if you have to work that hard, there’s probably a better way.
Since I started out on batch files in DOS days, I was aware of their…uhh…lets see, how shall I put this politely… deficiencies. Actually managing systems with batch files is not my idea of a good time, and so for a long time, I didn’t do it, but I kept hearing rumblings of another language on the horizon from Microsoft that could be used for effectively managing a system…and those noises were referring to Powershell.
A lot of you have tried powershell, and a lot of you like it. I know, because when I said on twitter that I was using it, some people spoke up very vocally and supported the idea, and gave me hints on what to try. On the other hand, some people went the other direction and accused me of “selling out”, which I thought was interesting, considering that I have nothing particularly against Microsoft, at least in terms of stuff I use at work. Anyway, a lot of people were very much shocked and dismayed at my use of powershell, because of the company that produced it. Lets move past that, be grown ups, and say “if it works for what we need, then we’ll use it”, because that is what system administration is about…getting the job done.
I’ve been playing with powershell now for about 6 hours total, and let me assure you, it helps get the job done.
There are some oddities, but overall, speaking as someone who comes from a background in bash and who is lightly conversational in perl and ruby, it’s a very familiar syntax style and methodology. It was obviously written by people who scripted a lot, because plenty of things that used to be hard are now very easy.
I’m probably going to do a “how to get your feet wet with powershell” post or two in the coming days, because I don’t know enough to instruct you beyond that, but let me show you some of the resources I’ve been using, and maybe you can beat me to the punch.
Windows XP or newer
Windows 7 (or Server 2008) are ideal, because they come with PowerShell and PowerShell ISE (the Integrated Scripting Environment, basically an IDE) preinstalled, but you can get Powershell 1.0 on XP and Server 2003, and Powershell 2.0 on Vista *shudder*.
I’ve actually been working through a book, Windows PowerShell 2.0 Administrator’s Pocket Consultant by Microsoft Press. It’s good, if a little slow. I’ve been supplementing it with some TechNet Script Center tasks. If you get a chance, I recommend working through the date/time example to see how powerful the language can be.
So far, I’m very happy with my new scripting language, particularly when I combine it with ultrapowerful addons, like the VMware Virtual Infrastructure PowerCLI, a VMware specific set of commandlets that let you address vCenter and ESX(i) hosts and guests (and clusters) programmatically. Even in the 6 hours I’ve been messing around, I’ve been able to do things that aren’t possible without a lot of hacking in shell scripts.
If you run Windows and you haven’t dug into powershell yet, it’s worth your time. I hope to show you some examples in the near future to kickstart your way.
If you use powershell, drop a comment and share your favorite tip. I’m eager to learn, and I know everyone else is, too!