Date post: | 01-Nov-2014 |
Category: |
Technology |
Upload: | concentrated-technology |
View: | 1,548 times |
Download: | 1 times |
Advanced Windows PowerShellError Handling, Debugging, “Script Cmdlets,” and More
Don Jones
Concentrated Technology
http://ConcentratedTech.com
This slide deck was used in one of our many conference presentations. We hope you enjoy it, and invite you to use it
within your own organization however you like.
For more information on our company, including information on private classes and upcoming conference appearances, please
visit our Web site, www.ConcentratedTech.com.
For links to newly-posted decks, follow us on Twitter:@concentrateddon or @concentratdgreg
This work is copyright ©Concentrated Technology, LLC
Agenda
• Crazy amounts of demo, very little slide• Shell transcript and samples will be
downloadable from ConcentratedTech.com by next week
• Error Handling• Debugging Techniques• “Script Cmdlets” (Advanced Functions)• Tips along the way
Errors in PowerShell
• Non-terminating errors take the behavior in $ErrorActionPreference
• Must make terminating to trap/handle• Use the –ErrorAction (-EA) parameter• Use –ErrorVariable (-EV) to capture the
error in a variable• Use Try…Catch to actually catch the error
Debugging
• Write-Debug to write trace code• Write-Verbose to write “progress” info• $DebugPreference, $VerbosePreference• -debug and –verbose for scripts• Also: PSBreakpoints
Advanced Functions
• A function that looks and works and smells like a “real” cmdlet
• Mainly just decorating function parameters and adding comment-based help
• Couple of cool tricks to support –confirm and –whatif
• Accept both pipeline and parameter input• Let’s make one
Pretty cool stuff, eh?
• Again – shell transcript/samples will be on ConcentratedTech.com by next week
Final Q&A
• Text DONJ to 50500 for contact info
• See me for add’l resources
● Books● Workshop recordings● Demo videos● Etc
• Slide decks posted to ConcentratedTech.com by next week
Your Feedback is Important
Please fill out a session evaluation form drop it off at the conference registration
desk.
Thank you!
This slide deck was used in one of our many conference presentations. We hope you enjoy it, and invite you to use it
within your own organization however you like.
For more information on our company, including information on private classes and upcoming conference appearances, please
visit our Web site, www.ConcentratedTech.com.
For links to newly-posted decks, follow us on Twitter:@concentrateddon or @concentratdgreg
This work is copyright ©Concentrated Technology, LLC