What is [cmdletbinding()] and how does it work?

后端 未结 3 1098
慢半拍i
慢半拍i 2020-12-11 00:14

According to get-help about_Functions_CmdletBindingAttribute

The CmdletBinding attribute is an attribute of functions that makes them operate like co

3条回答
  •  一整个雨季
    2020-12-11 00:50

    Generally speaking, CmdletBinding is what makes a function from an Advanced function. Putting it at the top of a script makes the script "advanced" script. Functions and scripts are much the same, where the script file name is equivalent to the function name and the script content is equivalent to the scriptblock section of a function.

    CmdletBinding attributes give you control over function capabilities, such as adding Confirm and WhatIf support (via SupportsShouldProcess), Disable parameters positional binding, and so on.

提交回复
热议问题