CHAPTER 5

image

Writing Reusable Code

This chapter will cover how to use PowerShell to write the most robust reusable code possible. To do this, we will discuss how to use CmdletBinding in our functions. There are two types of CmdletBinding attributes: general attributes and parameter-specific attributes. The general attributes control how the overall function behaves. The parameter-specific attributes give us control over each parameter, including value validation. When a parameter is not provided, a default value is given. PowerShell defaults may not be what you expect, so we’ll cover what they are and how to handle them. We’ll also review how to ...

Get Pro PowerShell for Database Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.