Why PowerShell?

Why am I writing a blog about PowerShell?  The answer is simple. I haven’t been as excited about a technology since I first learned SQL.  PowerShell allows me to do my job in a much more consistent, flexible, and scalable way.

What is it about PowerShell that has me so fascinated?

  • Ability to work with multiple technologies in a seamless fashion (.NET, WMI, AD, COM)
  • Dynamic code for quick scripting, strongly-typed code for production code (what Bruce Payette calls “type-promiscuous”)
  • High-level language constructs (functions, objects)
  • Consistent syntax
  • Interactive environment (REPL loop)
  • Discoverable properties/functions/etc. Example
  • Great variety of delivered cmdlets, even greater variety of community cmdlets and scripts
  • On a similar note, a fantastic community that shares results and research
  • Extensible type system MSDN
  • Everything is an object
  • Powerful (free) tools like PowerGUI, PSCX, PowerShell WMI Explorer, PowerTab, PrimalForms Community Edition, and many, many more.
  • Easy embedding in .NET apps including custom hosts.
  • The most stable, well-thought out version 1.0 product I’ve ever seen MicroSoft produce.
  • An extremely involved, encouraging community..

I have to admit that it wasn’t until the third time I looked at PowerShell that I finally “got it”.  I guess I didn’t have a problem in mind when I looked at it and was a bit overwhelmed by the syntax.  I think that trying to explain PowerShell as a “replacement for cmd.exe” really made it hard to see how all the new concepts (noun/verb combinations, for example) were going to pay off.  After all,cmd.exe is pretty painless to work with.  You can’t do much, so it’s not so hard.  With PowerShell, on the other hand, the sky’s the limit.

My first extensive use of PowerShell was to pull lists of shares from all of the servers that our group manages (about 450) along with Share and NTFS security.  Even to someone who hadn’t really ever used WMI, it was not too bad.

Once I had finished that, I started writing administration scripts for a purchased software package that used several different technologies and again spanned several servers.  We have about 60 different installations of this package on about 200 servers.  Managing them all through remote desktop and scheduled tasks was working, but was rapidly  becoming a maintenance nightmare.  PowerShell scripting has made the automation of most of our administrative tasks fairly painless.

I realize that this post was pretty low on technical details, but I hope to be following with several posts that include actual code. I’ve written several thousand lines of script and a custom PowerShell host, so I hope that something I write about is interesting and informative to you.

Feel free to comment if you have suggestions for topics you’d like to see me discuss.

Mike