Writing Scripts

  • Bryan Cafferky

Abstract

This chapter focuses on PowerShell features critical to developing professional code. We will start by discussing the Set-StrictMode cmdlet that protects us from uninitialized variables, incorrect method calls, and invalid property references. Then we’ll discuss how to gracefully handle errors raised when your scripts execute. Error handling leads us into a discussion of common cmdlet parameters, so called, because all the built-in cmdlets support them. Then we introduce the PowerShell Integrated Script Environment’s debugging features. Since PowerShell has excellent support for event-driven programming, we proceed with a discussion of implementing Windows forms and events to provide a GUI for our scripts. Building on this, we show how events can be used with other .NET objects. Then we discuss PowerShell’s implementation of transaction support via a set of special cmdlets. This is an important section, as PowerShell transactions are not what we might expect. Finally, we will briefly discuss the PowerShell ISE options; what they do, and how to use them. It is easy to overlook these features, but they can make development easier.

Keywords

Trap Statement Error Message Form Object Transaction Support Window Form 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Copyright information

© Bryan Cafferky 2015

Authors and Affiliations

  • Bryan Cafferky
    • 1
  1. 1.MAUS

Personalised recommendations