11 Getting started with advanced functions
We’re almost there, we promise, but before we can start writing our own advanced functions, we’ll focus entirely on the Param()
block of the example function in this chapter and discuss some of the cool things you can do with it.
11.1 About CmdletBinding and common parameters
What’s the difference between a simple function and an advanced function? It may surprise you to know that it’s just a single line of code—the CmdletBinding()
attribute. This attribute adds so much functionality—let’s take a look. To illustrate the first major difference, let’s start with a basic function:
function test { Param( [string]$ComputerName ) }
That’s it—no code at all. Now ask PowerShell for help with that function: ...
Get Learn PowerShell Scripting in a Month of Lunches, Second Edition 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.