PowerShell Troubleshooting Guide

Minimize debugging time and maximize troubleshooting efficiency by leveraging the unique features of the PowerShell language

PowerShell Troubleshooting Guide

Starting
Michael Shepard

1 customer reviews
Minimize debugging time and maximize troubleshooting efficiency by leveraging the unique features of the PowerShell language
$17.99
$29.99
RRP $17.99
RRP $29.99
eBook
Print + eBook

Instantly access this course right now and get the skills you need in 2017

With unlimited access to a constantly growing library of over 4,000 eBooks and Videos, a subscription to Mapt gives you everything you need to learn new skills. Cancel anytime.

Preview in Mapt

Book Details

ISBN 139781782173571
Paperback206 pages

Book Description

Windows PowerShell provides an amazing platform for administrative scripting and automation. Understanding the PowerShell language will enable you to spend less time troubleshooting and be more effective when debugging is required. PowerShell also includes several avenues to provide feedback from your code that will make your troubleshooting and debugging time more profitable.

Improved coding practices combined with useful diagnostic information can lead to results quickly. This book starts with background information on the purposes of automation and PowerShell's entrance into Microsoft's automation strategy, and also answers the question of whether scripting (and specifically PowerShell scripting) is essentially different than traditional programming. A brief overview of the main features of the PowerShell language along with examples is provided. Focus is placed on proper script design and use of PowerShell features in an attempt to reduce the need for troubleshooting.

Table of Contents

Chapter 1: PowerShell Primer
Introduction
Cmdlets
Functions
Scripts
Pipelines
Variables
Modules
Further reading
Summary
Chapter 2: PowerShell Peculiarities
PowerShell strings
Function output
Pipeline processing
PowerShell error handling
Further reading
Summary
Chapter 3: PowerShell Practices
Filter left
Format right
Comment-based help
Using Write-* cmdlets
Further reading
Summary
Chapter 4: PowerShell Professionalism
Naming conventions
Modularization
Version control
Unit testing
Further reading
Summary
Chapter 5: Proactive PowerShell
Error handling
CmdletBinding()
SupportsShouldProcess
Parameter value validation
Pipeline input
Pipelines and function execution
Parameter type transformation
#REQUIRES statements
Set-StrictMode and Set-PSDebug -strict
Further reading
Summary
Chapter 6: Preparing the Scripting Environment
Validating operating system properties
Validating service status
Validating disk and memory availability
Validating network connectivity
Further reading
Summary
Chapter 7: Reactive Practices – Traditional Debugging
Reading error messages
Using Set-PSDebug
Debugging in the console
Debugging in the ISE
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
Chapter 8: PowerShell Code Smells
Code smells
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
Further reading
Summary

What You Will Learn

  • Utilize PowerShell output cmdlets to provide the troubleshooting information you need
  • Use pipeline input in your functions to reduce parameter passing issues
  • Use Write-* cmdlets to expose the right kind of information in the right places
  • Control the environment to eliminate surprises when executing scripts
  • Create powerful scripts and functions that communicate expectations
  • Write unit tests for your PowerShell functions and scripts to ensure that they can be executed correctly

Authors

Table of Contents

Chapter 1: PowerShell Primer
Introduction
Cmdlets
Functions
Scripts
Pipelines
Variables
Modules
Further reading
Summary
Chapter 2: PowerShell Peculiarities
PowerShell strings
Function output
Pipeline processing
PowerShell error handling
Further reading
Summary
Chapter 3: PowerShell Practices
Filter left
Format right
Comment-based help
Using Write-* cmdlets
Further reading
Summary
Chapter 4: PowerShell Professionalism
Naming conventions
Modularization
Version control
Unit testing
Further reading
Summary
Chapter 5: Proactive PowerShell
Error handling
CmdletBinding()
SupportsShouldProcess
Parameter value validation
Pipeline input
Pipelines and function execution
Parameter type transformation
#REQUIRES statements
Set-StrictMode and Set-PSDebug -strict
Further reading
Summary
Chapter 6: Preparing the Scripting Environment
Validating operating system properties
Validating service status
Validating disk and memory availability
Validating network connectivity
Further reading
Summary
Chapter 7: Reactive Practices – Traditional Debugging
Reading error messages
Using Set-PSDebug
Debugging in the console
Debugging in the ISE
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
Chapter 8: PowerShell Code Smells
Code smells
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
Further reading
Summary

Book Details

ISBN 139781782173571
Paperback206 pages
Read More
From 1 reviews

Read More Reviews