"Windows PowerShell Scripting and Toolmaking" by Don Jones
Interface Technical Training | 2011 | ISBN: 9781105082856 | 105 pages | PDF/epub/mobi | 1 MB
Interface Technical Training | 2011 | ISBN: 9781105082856 | 105 pages | PDF/epub/mobi | 1 MB
Using a step-by-step process, this book leads you through error handling, debugging, function creation, module manifests, and other key topics, providing complete real-world examples each step of the way. This edition has been formatted to provide the best possible experience for reading code listings in an ebook format, given the limitations of ebook readers.
Take PowerShell further by turning interactively-run commands into reusable, packaged, distributable tools! Learn to parameterize commands, work with advanced functions and modules, create multi-file modules, develop custom views, work with databases, and much more - all from the world's most-published PowerShell expert, MVP Award recipient Don Jones.
Contents
Introduction
Typesetting Standards
Editing Scripts
An Organic Approach
Welcome to Tier 2
Acknowledgements
Scripting Overview
PowerShell Script Files
Variables
Quotation Marks
Object Members and Variables
Parentheses
Scope
PowerShell Scripting Language
If Construct
Do…While Construct
ForEach Construct
Other Constructs
Functions
Adding Parameters to a Script
Advanced Scripts
Conclusion
Advanced Functions
Advanced Function Template
Designing the Function
Declaring Parameters
Testing the Parameters
Writing the Main Code
Outputting Custom Objects
Continuing With the Advanced Function
Testing the Function
Conclusion
Advanced Functions, Advanced
Testing, Testing, Testing
Verbose and Debug Output
Parameter Aliases
Parameter Validation
Parameter Help
Parameter Sets
Designing Functions
Conclusion
Error Handling
It's All About the Action
Setting the Error Action
Saving the Error
Error Handling v1: The Trap Construct
Try…Catch…Finally
Debugging
Two Types of Bugs
Solving Typos
Dealing with Logic Errors: Trace Code
Dealing with Logic Errors: Breakpoints
The Real Trick to Debugging
Custom Formatting
The Anatomy of a View
Adding a Type Name to Output Objects
Making a View
Loading the View
Problems at this Point
Script and Manifest Modules
Introducing Modules
Creating a Module Manifest
Creating a Module-Level Setting Variable
Writing Help
Comment-Based Help
XML-Based Help
Using Databases
Simplifying Database Access
Setting Up Your Environment
The Database Functions
About the Database Functions
Using the Database Functions
Closing Thoughts
A Final Lesson: Script Design
Appendix: Best Practices
with TOC BookMarkLinks