Skip to Main Content
Learn PowerShell Scripting in a Month of Lunches, Second Edition
book

Learn PowerShell Scripting in a Month of Lunches, Second Edition

by James Petty, Jeffery Hicks, Don Jones
April 2024
Beginner to intermediate content levelBeginner to intermediate
336 pages
8h 51m
English
Manning Publications
Content preview from Learn PowerShell Scripting in a Month of Lunches, Second Edition

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: ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learn PowerShell Scripting in a Month of Lunches

Learn PowerShell Scripting in a Month of Lunches

Jeffery Hicks, Don Jones
Learn PowerShell in a Month of Lunches, Fourth Edition

Learn PowerShell in a Month of Lunches, Fourth Edition

Tyler Leonhardt, Travis Plunk, James Petty

Publisher Resources

ISBN: 9781633438989Supplemental ContentPublisher SupportOtherPublisher WebsiteSupplemental ContentPurchase Link