PowerShell Not your Father’s Command Line Part 1 of 31: Why PowerShell?

imageWelcome to the inaugural post of 31 posts during the month of May on Windows PowerShell 2.0.  Sarah (my co-author extraordinaire) and I thought it would be a good idea to share some tips and insight to get you started with this fabulous tool PowerShell. So over the next month and beyond you will see posts on both of our blogs on PowerShell.  Whether you are an IT Pro or Developer it is our hope you begin to look at this tool in a new light and ultimately put this in your bat belt of utilities.  This may also lead you wanting to learn more about this great language, and maybe you might want to buy our book Automating Microsoft Windows Server 2008 R2 with Windows PowerShell 2.0 that will be released sometime in the middle of this month.  What can you expect for the next month for the posts?  The posts will be designed to get you started, provide some insight,  examples and hopefully have some fun as you go on the journey of working with and learning PowerShell.  So where to begin, I guess it would be the question we all start with:

What in the world is PowerShell?

PowerShell is the next generation scripting language that was formed out of numerous customer requests to have a single powerful scripting language for the Windows platforms.  PowerShell may be a command-line tool, but Windows PowerShell can accomplish all of the tasks that graphic management tools can—and often more quickly and easily, and with less intervention from you. Windows PowerShell is a powerful and complete scripting language which supports:

  • Branching
  • Looping
  • Functions
  • Debugging
  • Exception handling
  • internationalization and etc. 

Windows PowerShell is ideally suited for performing repetitive bulk operations in a consistent fashion. For example, if you have to create mailboxes for 1,000 user accounts, the Exchange Management Console process would be slow and tedious. But you can achieve the same objective with a few simple commands in PowerShell. Exchange administrators were the first to benefit from this language.  As a shell  it provides a powerful, flexible, and scriptable command-line experience that allows you to perform virtually any administrative tasks.  Scripts and commands can be used to automate repetitive tasks, such as producing reports on mailbox usage.  Windows PowerShell is not a text-based shell, but instead uses an object model based on the Microsoft .NET platform. It has a substantial number of built-in commands that provide you with a powerful tool set for script-based administration that can interoperate with .NET objects and data.  Sometimes it is affectionately referred to as .NET on the command line!  It is this distinction that should start to open the eyes of Developers and this also provides a huge world of value to anyone leveraging this language. 

Why should you care?

If you are doing anything with scripting today, the answer is simple:  Why Not!   More importantly if you are not but are looking to perform repeatable tasks, then this language is for you!  PowerShell is now built-in to many Microsoft products and Operating systems and is the preferred scripting language of choice in a majority of Microsoft applications.  With many of the new products having PowerShell baked in, the why is really a no brainer if you do anything with scripts today.  You might be thinking, but Matt I already use VB script for my scripting environment.  Trust me when I say you will find PowerShell scripts to not only be shorter but also easier to write and not as picky, and for lack of a better word, more PowerFull.  At the end of the day, this is a language that can help save you time effort and hopefully headaches (look for a future post on the AD recycle Bin to see what I mean), so stick with us over the next month and hopefully at the end you will find many uses for PowerShell in your environment!

Lastly these postings for the month are designed to be fluid.  If there is a topic on PowerShell you are curious about and would like Sarah or myself to cover in these postings, all you need to do is ask.  Email either of us with your comments or suggestions, we look forward to hearing from you.