Using Windows? Try Powershell!

Recently, at work I’ve had to implement a couple of simple scripts. They were yet again not simple enough to be captured completely in a batch file. For example I needed to have an arbitrary precision and format date/time that I could use in a file name. date /t and time /t weren’t cutting it.

I thought about implementing a small command-line tool just to give me the functionality I was missing, but it felt too patchy for my taste, this time. I had to use it on other test machines so I wanted to be able to just copy the script without having to update some executable utilities as well.

Sadly I could not use Ruby because my company doesn’t use it, and I don’t want to sneak it in the wrong way. And as I said it was to be used on another machine, so it was not like creating a personal script on my own machine. In fact it even had to be documented in a manual testing procedure.

So I decided that it was time to try Powershell. I’ve been hearing about it for quite a while now, and I heard it’s pretty powerful. Since it’s the future of Windows console/scripting anyway, I figured nobody sane at a Windows shop would yell at me for introducing this particular technology.

Now that I’ve been dabbling with it for the past few weeks, my opinion is starting to form and it goes a little bit like this. If you’re a Windows power user (especially an admin or a developer) and you don’t know Powershell, you’re at a disadvantage :-) The “Power” in Powershell is very well deserved. If you’re still flopping along using batch files, you’re using a weak, error-prone tool where a new, very powerful tool is available. It’s free and it’s by Microsoft, so there’s no reason it wouldn’t be well received in most Windows shops :-)

I decided to capture my understanding of Powershell in an introductory article. In it I explain some of the basics of the language and introduce you to all that’s necessary to get started with Powershell. In the reference section at the end I also mention other good sources of information if you want to learn more. Depending on the amount of fiddling around you do while following along, I guess it’s a 30 minutes to 2h read tops.

So without further ado, Discover Powershell (it’s an order!)