This article is more than 1 year old

Welcome, stranger: Inside Microsoft's command line shell

A walk through the back office, from MS-DOS to PowerShell

You can be sure of PowerShell

Since Exchange in 2007, more and more of Microsoft's platforms and systems have been launched with PowerShell functionality.

PowerShell is now everywhere in the Microsoft landscape. It's expected to be a part of any product, and can even be used to manage Microsoft's Azure. For those using PowerShell, it's now loved by most. But for those who haven't dipped their toe into the blue PowerShell waters, they might be wondering why people are so passionate about it.

At the fundamental level, there are many differences between the old and new. Cmdlets are the first item you'll be exposed to, and are used in a verb-noun format. Instead of dir, you'd run the command get-childitem. That's a lot more effort to type, but in PowerShell all the results you get back are objects, not plain text. The objects can be manipulated and filtered in a much easier way than was possible in the old command prompt.

There's so many little bonuses you'll find when using PowerShell, such as the -whatif switch. Throw that on the end of any supported command you're about to run, and you'll be told what would happen if you really ran the command. A simple check that could save you from causing a crazy amount of harm to your environment.

Remember how I mentioned auto completion for the command line? PowerShell takes this to a whole new level. Not only can you auto complete any command – such as get-ch <tab;&gt, resulting in get-childitem – but you can cycle through switches for the command by pressing tab again, after get-childitem, if you're not sure what ones are available.

Piping is the next powerful ability of PowerShell. Piping uses the pipe symbol | to split commands and feed the latter to the former. So get-childitem | where name -notlike Windows would show you the directory listing, but excluding anything that matches the name Windows. You can't do that with a single command prompt line.

PowerShell also contains a powerful but simple scripting language, along with a sophisticated error handling mechanism. Depending on the command, you'll often be told exactly what you've done wrong. For example, if you've used a switch to a command that doesn't exist, you'll generally get back a nice red error that says which exact character the problem occurred at, and what the bad command was:

There is also the Windows PowerShell Integrated Scripting Environment (ISE) program, which is helpful for writing and troubleshooting commands or scripts. You can debug your command or code, and selectively run parts of it. Colour coding parts of commands shows you've got your syntax correct, and it's use just adds to the experience of using PowerShell.

PowerShell has seen five major versions since its release in 2006 and is only now finally getting the recognition it deserves as the default go-to command line for an IT professional, rather than the incredibly dated command prompt.

If you haven't already started using it, you're lagging behind and should use this tool to automate menial tasks you're performing manually. It takes practice, but it's a move you won't regret. ®

More about

TIP US OFF

Send us news


Other stories you might like