Original article address:Http://app.en25.com/e/es.aspx? S = 1403 & E = 5441 & elq = 3d32771b868b437aa97567a6a50b5563
Original article:
Mandatory parameters are special because if you do not submit it, powershell will automatically ask for it. you can use mandatory parameters in your own functions as well. you shoshould simply mark a function as mandatory by adding the appropriate [parameter ()] attribute like so:
Function Test-me {
Param (
[ Parameter ( Mandatory = $ True )]
$ Name
)
"You entered $ name ."
}
Test-me
The parameter attributes used in this tip were introduced with powershell V2.
Translation:
MandatoryThe parameter is special because this parameter is not submitted,PowershellIt will automatically let you enter. You can also use it in your own functions.MandatoryParameters. You only need to mark[Parameter ()]You can mark the attribute before the method, for example:
Function Test-me {
Param (
[ Parameter ( Mandatory = $ True )]
$ Name
)
"You entered $ name ."
}
Test-me
This parameter attribute is used inPowershell v2Has been introduced.
Notes:
MandatoryThe meaning of the corresponding Chinese characters here is not very clear, forced? Obligation? Mandatory?
The last sentence is not very understandable.