O'Reilly logo

Windows PowerShell™ 3.0 Step by Step by Ed Wilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The [cmdletbinding] attribute

The first step in creating an advanced function is to add the [cmdletbinding] attribute to modify the way the function works. This single addition adds several capabilities, such as additional parameter checking and the ability to use easily the Write-Verbose cmdlet. To use the [cmdletbinding] attribute, you place the attribute in a square-bracket attribute tag and include it in the first noncommented line in the function. In addition, the [cmdletbinding] attribute requires the use of the Param keyword. If your advanced function requires no parameters, you can use the Param keyword without specifying any parameters. This technique appears here:

function my-function
{
 [cmdletbinding()]
 Param()

}

Once you have the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required