PowerShell Troubleshooting Guide
图书信息
| 作者 | Michael Shepard |
| 出版社 | Packt Publishing |
| ISBN | 9781782173588 |
| 出版时间 | 2014-11-28 |
| 字数 | 70.4万 |
| 分类 | 进口书,外文原版书,电脑,网络 |
读书简介
The techniques in this book apply to beginners who have just started to learn PowerShell, as well as advanced *ers who have a good grasp of the language.
目录
PowerShell Troubleshooting Guide
Table of Contents
PowerShell Troubleshooting Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Instant updates on new Packt books
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. PowerShell Primer
Introduction
Cmdlets
The big three cmdlets
Functions
Scripts
Pipelines
How pipelines change the game
What's the fuss about sorting?
Variables
Modules
Further reading
Summary
2. PowerShell Peculiarities
PowerShell strings
String substitution
How string substitution goes wrong
Escaping in PowerShell strings
Function output
Pipeline processing
PowerShell error handling
The trap statement
try, catch, and finally statements
Non-terminating errors
Further reading
Summary
3. PowerShell Practices
Filter left
Format right
Comment-based help
Using Write-* cmdlets
Write-Host
Output – the correct way
What about the other Write-* cmdlets?
Which Write should I use?
Write-Verbose
Write-Debug
Write-Warning
Write-Error
Write-Progress
Further reading
Summary
4. PowerShell Professionalism
Naming conventions
Cmdlet and function naming
Parameter naming
Module naming
Variable naming
Modularization
Breaking a process into subtasks
Helper functions
Single responsibility principle
Don't repeat code
Understanding the process
Version control
Using version control with PowerShell
Unit testing
Rolling your own unit tests
Why is PowerShell testing difficult?
An introduction to Pester
Mocking with Pester
Further reading
Summary
5. Proactive PowerShell
Error handling
Error-handling guidelines
Error-handling techniques
Investigating cmdlet error behavior
Catch and release
CmdletBinding()
Common parameter support
SupportsShouldProcess
Parameter name validation
Parameter value validation
Pipeline input
Pipelines and function execution
Parameter type transformation
#REQUIRES statements
Set-StrictMode and Set-PSDebug -strict
Further reading
Summary
6. Preparing the Scripting Environment
Validating operating system properties
Workstation/server version
Operating system version
Putting it all together
Validating service status
Validating disk and memory availability
Validating network connectivity
Using telnet
Using Test-NetConnection
Writing Test-NetConnection in downstream versions
Testing UDP and ICMP connectivity
Validating connectivity prior to implementation
Putting it all together
Further reading
Summary
7. Reactive Practices – Traditional Debugging
Reading error messages
The color problem
Changing console colors
Changing ISE colors
PowerShell profiles
Error message content
Using Set-PSDebug
Debugging in the console
Debugging in the ISE
Event logs
Listing event logs
Reading event logs
Writing to event logs
The PSDiagnostics module
Using –confirm and –whatif
Reducing input set
Using Tee-Object to see intermediate results
Replacing the foreach loop with the foreach-object cmdlet
Further reading
Summary
8. PowerShell Code Smells
Code smells
Code smells, best practices, antipatterns, and technical debt
Language-agnostic code smells
PowerShell-specific code smells
Missing Param() statements
Homegrown common parameters
Unapproved verbs
Accumulating output objects
Sequences of assignment statements
Using untyped or [object] parameters
Static analysis tools – ScriptCop and Script Analyzer
ScriptCop
Script Analyzer
Further reading
Summary
Index
- 纸上王国(邓安庆)
- PHP入门很轻松(微课超值版)(云尚科技)
- 未解之谜(下)(百读)
- 粗糙且含糊不清的怪盗预告信:警察厅特案专职搜查课事件簿([日] 仓知淳)
- 分开以后我变成了你喜欢的样子(Josie乔)
- 图说天下学生版 超级兵器传奇 世界王牌武器陆海空大阅兵(套装共3册)(试读本)(薛金冉 编著)
- Delphi Collected Poetical Works of John Gower (Illustrated)(John Gower)
- 建设工程监理案例分析(仅适用PC阅读)(执业资格考试命题研究中心)
