I’ve become an increasing fan of Windows PowerShell. It’s additional use of variables, scripts, and libraries opens up doors to some powerful scripting options that I need. I’m working on creating some deployment scripts for web applications I maintain across various web servers, and simple batch files wouldn’t fit the bill. Having worked a little bit with PowerShell, I really needed something that would provide a reference guide for all the tasks I wanted to accomplish. I also needed to learn a bit more about the fundamental concepts and features of PowerShell itself. Windows PowerShell Cookbook, 3rd Edition by Lee Holmes provides that provides the examples and reference guide necessary for nearly all of my PowerShell needs.
Like most “cookbook” style O’Reilly books, the first chapter of the book provides an brief overview of Windows PowerShell. It outlines the core concepts of structured commands (also known as cmdlets) and how you can use deep object integration (you can grab the entire notepad application process as a variable) with PowerShell. Other topics like ad-hoc scripting (chaining PowerShell commands at the command prompt) are also covered as well.
From there, the book expands to cover specific tasks and the PowerShell code to execute them. Each task (or recipe) provides a top level explanation, execution examples (and sometimes expected output), and the full code itself. This allows you to easily copy and paste (code is available online) these scripts and add them as your own for your work.
What’s really nice is that the recipes progress in complexity as well as give you some “cooking directions” about what is happening. While the first couple of chapters give you recipes dealing with the fundamentals, the subsequent chapters deal with pipelines (taking the results of one command and sending it to another), variables, looping, and so on. That way complete beginners (such as myself) can build their knowledge of of PowerShell without feeling completely lost.
By the end of the book, you will have recipes for Internet enabled scripts (pushing files to a remote server), creating zip archives, and working with user input to help dictate the names of files/folders that are to be modified. All of this is exactly what I need to create my deployment scripts for my sites.
Windows PowerShell Cookbook, 3rd Edition is an essential book to any programmer. It is structured in a way that beginners can read through the book and build up their skills along the way. Veteran developers can use it as a handy reference guide, complete with fully functional samples. It is a must have book for anybody working with Windows PowerShell.
You can get this book through O’Reilly Books at http://shop.oreilly.com/product/0636920024132.do.