by Kyle Berger, Senior Taos Technical Consultant
A whole lot, that’s what!
First, let us take a look at the name. Normally, I would say “What’s in a name?” but Powershell’s name actually holds some meaning. The first word, ‘Power,’ adequately describes the language, which is quite powerful. It was clearly designed from the ground-up to be a purebred full-throttle administration tool. And ‘Shell’ simply means it is a command-line user interface. Think of Powershell as a powerful command-line administration interface, and you know why they call it that.
Is Powershell perfect? No. Has it come a long way? I’d like to think so.
And now for something completely different
For anyone familiar with Bash, transitioning to Powershell shouldn’t be difficult at all. In fact, it may be easier than you think. Commands such as ls, man, cat, echo, mv, rm, etc., are aliases to Powershell commands that come built-in with Powershell 4.0. You can even easily create your own aliases to feel even more at home transitioning to Powershell from the long revered Linux/Unix world. If you happen to be lucky enough to be working with Powershell 4.0 and the wonderful Powershell ISE (Integrated Scripting Environment), you may even start to enjoy Windows Administration!
I can’t tell you how many times I’ve been told something is impossible or not worth the time and effort, and I chime in with:
As an example of the efficient workflow that is capable in the ISE, check out what appears as soon as I start typing a command:
You can auto-complete your desired cmdlet, called a ‘Command-let’ in Powershell, by selecting the desired cmdlet and pressing Tab or Enter. I know they put the Tab selection in there for the Linux folks out there, just to make you smile on the inside. Nice of Microsoft to do that, no?
All of the parameters are laid out for you at a glance, including the variable type to use. If you need more detail on a particular command, type ‘man <cmdlet> -full’ and you can see extremely granular information about each and every parameter, including examples with descriptions of what is happening. The best part? Each and every help file is formatted exactly the same as all the rest! I like Linux, but sometimes reading a man page is more difficult than it needs to be. Do I use –r or –R? Hopefully the man page gives me enough detail.
To string or not to string?
In an effort to not sound like a Linux hater, there are some key annoyances with Powershell. The largest difference between Linux, which is almost entirely text-based, and Powershell, which is almost entirely object-based, is dealing with command output. It can take a lot of getting used to. Is a given object property a simple string, an array of strings, a custom object with its own sub-properties, all of which are different types of variables? This goes on and on. Luckily there are easy ways to determine this kind of information, but it needs to be checked often, to make sure you are treating output as it needs to be treated. Basically, you can output just about everything as a string if you wish, but handling output can be a bit of a chore if you aren’t aware of the best way to get the output you want, given your needs. In Linux, there’s no guess work; everything is text.
I think I’ll end it there for now, but I intend to continue looking into Powershell and its key features, differences with other command-line interfaces, and limitations in follow up posts. On my next post, I want to delve into the Powershell pipeline, which will be familiar in many ways to Linux Administrators, and really shows where Powershell shines given its object-oriented nature.
See you next time!