O'Reilly logo

PowerShell Troubleshooting Guide by Michael Shepard

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. Proactive PowerShell

PowerShell includes capabilities to improve the quality of scripts that will prevent some of the problems that might be encountered in the scripting process. In this chapter, we'll cover the following topics:

  • Error handling (try/catch versus trap)
  • Parameterization and pipeline input
  • Pipelines and function execution
  • Parameter validation
  • Parameter type transformation
  • Strictmode/PSDebug
  • #REQUIRES statements (version or administrator)
  • CmdletBinding and common parameters

Error handling

Chapter 2, PowerShell Peculiarities introduced PowerShell's two error-handling mechanisms: the trap statement and the try, catch, and finally statements. That chapter explained how these statements function in PowerShell code. The following sections ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required