Chapter 11. Going advanced with your function

In this chapter, we’ll focus entirely on the Param() block of the example function and discuss some of the cool things you can do with it.

11.1. About CmdletBinding and common parameters

Back when PowerShell v2 was being developed, Microsoft toyed with the idea of having a cmdlet{} construct that was essentially a superset of function{}. The idea was that these “script cmdlets” would exhibit all the behaviors of a “real” cmdlet (for example, one written in .NET and compiled into an assembly). By the time v2 released, these had become advanced functions, and they’re differentiated primarily by the [CmdletBinding()] attribute. To illustrate the first major difference, let’s start with a basic function: ...

Get Learn PowerShell Scripting in a Month of Lunches 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.