0 0 1 461 2629 Concentrated Technology 21 6 3084 14.0 Normal 0 false false false EN-US JA X-NONE
Chapter 25 made me feel like I was at work, but, in a good way. These sorts of functions/scripts are the bread and butter of my more robust projects, tasks where I get to stop, think, and, build truly automated solutions. Sadly, I must admit, many of my scripts are more of the variety used to plug a leaky engine, or, stop a fire. When I have time to really reflect on building well thought out scripts, sometimes I balk because I have time to overcomplicate things. That is one warning I would give to people. PowerShell gives people a lot of chances to make things more complex than they need to be. Remember the key to PowerShell is the old KISS principle: Keep It Simple Scripter. Programmers have time to build ornate machines. Scripters typically need to get the job done and move on.
I have to admit, while there were a few things I had to think about to pull this off, I found it to be a great exercise. For me a lot of the latter elements mentioned in the book came to life. For instance, where Don says Chapters 20 and 22 would come into play, he was right. I found it interesting that the alias I added to the param block did not get automatically picked up by the PowerShell ISE. What gets recognized by default and what gets overlooked baffles me at moments.
Also, the way I approached some of the function was to use begin/process/end. Looking back a few chapters how the process block eliminates the need to iterate over a collection came to mind. I think this will be a big part of my plans moving forward. In fact, there were lots of cool approaches used in this chapter that explored more robust sides of automation and scripting than I had been aware of before starting the book. If only I could get people at my office to give me project scoped this nicely! (And that includes me.)
The approach where you build custom objects was on my mind from the start. However, even though I had the basics down I had to cheat a little. NoteProperty will not work if you put NoteScript. Simple issues that can be resolved by looking at the help (or in this case the teacher's answer key) made it possible to get this script done pretty quickly. I have to admit, even though I did not remember the need to use Write-Output with custom PSObjects it flashed back and helped me get the script up and running.
Overall, I see this script as a practical introduction to what real-world, professional grade PowerShell should look like. To me there are many next steps, but, a Learn Windows PowerShell Enterprise Scripting in a Month of Lunches is not a book most would be interested in. It is at this point that, having been brought up to speed, it is time to branch out into other books, perhaps, rereading Don and Jeff Hicks' v2 TFM. Or perhaps I should be getting excited for the v3 In Depth release where what I learned how to do with Chapter 25 goes from one script to a full-scale process automation. At this point, you should be ready to spread you wings a little bit. I know I have some places bookmarked for reference later. Chances are I'll be rereading once a year or so.
Mar 28 2012, 04:36 PM