开发者

not using [parameter()] on some parameters in a PowerShell advanced function

开发者 https://www.devze.com 2023-02-16 02:17 出处:网络
If you are doing advanced functions and have the parameters decorated [parameter()], would there be any reason to NOT decorate a parameter with [Parameter()] . I\'ve seen this a few times and don\'t k

If you are doing advanced functions and have the parameters decorated [parameter()], would there be any reason to NOT decorate a parameter with [Parameter()] . I've seen this a few times and don't k开发者_Python百科now whether its just a case of laziness, oversight, or purposeful design.


Laziness I think but to be fair, it isn't needed if you aren't using any special parameter attibutes like Mandatory, Position, etc. As long is one parameter is marked [Parameter(...)] or the param block is marked [CmdletBinding(...)] PowerShell will interpret that function as an advanced function. OTOH there is no harm in adding the empty [Parameter()] to parameters.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号