PowerShell
I’ve been learning Microsoft’s new PowerShell. I have to admit, I am really impressed. They’re finally putting an emphasis on the command line, and giving us some powerful tools to manipulate Windows systems programatically.
I’ve never been much of a developer, but I’ve certainly hacked together some scripts over the years. That’s included batch files and a bit of VBScript on the Windows side, and some shell scripting on the UNIX side. I’ve put together a little bash script that runs via cron to backup my main workstation, for example.
PowerShell essentially gives Windows the power of a UNIX shell, with some new advantages. The two most exciting ones:
- The command syntax is consistent. Every command follows the same naming scheme and the same ways of passing arguments. It’s always driven me a little crazy that many UNIX commands have obscure names and the syntax is wildly different across commands.
- PowerShell “cmdlets” output information as objects. So instead of parsing text you can just grab a specific attribute by name from the object returned by the cmdlet. Pretty sweet.
PowerShell pipes from one cmdlet to the next via the familiar “|” character, system processes can be started and killed, text output can be imported from and exported to CSV, HTML and XML. Various “provider” services give access to other parts of the system. For example, a registry provider allows access into the registry at the command line and a WMI provider allows access to the Windows Management Instrumentation.
I’m looking forward to automating more tasks and getting more skilled at this new and nifty (yes, I said, “nifty”) shell.