와 필수 cmdlet은 매개 변수에 기본값 : cmdlet을 호출공급 cmdlet에 클래스 가정 할 ValidateSet
[System.Management.Automation.Cmdlet(System.Management.Automation.VerbsCommon.Get, "LogonToken")]
public class GetLogonToken : System.Management.Automation.Cmdlet
{
// constructor
public GetLogonToken()
{
// set default auth.
this.Authentication = "secWinAD";
}
// addtional properties omitted
[System.Management.Automation.Parameter(Position = 1, Mandatory = true)]
[ValidateSet("secEnterprise", "secLDAP", "secWinAD")]
public string Authentication
{
get { return authentication; }
set { authentication = value; }
}
// setting authentication here has no effect either
private string authentication;
// addtional code omitted
}
을 : 나는 필수 매개 변수에 기본값을 할당하려면 어떻게
PS ..\bin\Debug> get-logontoken
cmdlet Get-LogonToken at command pipeline position 1
Supply values for the following parameters:
ServerName: SERVER
Authentication: <hit enter>
Username: USERNAME
Password: ********
Get-LogonToken : Cannot validate argument on parameter 'Authentication'. The
argument "" does not belong to the set "secEnterprise,secLDAP,secWinAD"
specified by the ValidateSet attribute. Supply an argument that is in the set
and then try the command again.At line:1 char:1
+ get-logontoken
+ ~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-LogonToken], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,PsEnterprise.GetLogonToken
을 그 ValidateSet
을 사용합니까?
제목에 오타를 수정하십시오 :'manditory' – wOxxOm