What is the difference between PSCredentialUIOptions.Default and PSCredentialUIOptions.ValidateUserNameSyntax?

One of the overloads in PowerShell for a method $Host.UI.PromptForCredentialhas a parameter options, which is a bitwise combination of values PSCredentialUIOptions.

Looking at the MSDN for PSCredentialUIOptions I find that the enumeration values ​​include:

Default : checks the username, but not its existence or correctness.

and

ValidateUserNameSyntax : checks the syntax of the username, but not its existence or correctness.

What exactly do these descriptions mean?

By default, when he checks the username, does this mean that he simply checks that the user entered something, something in the "Username" field of the "PSCredentials" dialog box?

And for ValidateUserNameSyntax, how does it check the username syntax? Checking for invalid characters in the entered text?

I tried Google for more information, but all the links just returned to the MSDN page or on the same TechNet page.

+4
source share
1 answer

Not only ValidateUserNameSyntaxchecks for invalid characters, but also checks the format of the username on allowedCredentialTypeswhich you point to PromptForCredential():

$PromptCaption = "Creds plz!"
$PromptMessage = "Please input your domain credentials"

$CredentialType = [System.Management.Automation.PSCredentialTypes]::Domain
$ValidateOption = [System.Management.Automation.PSCredentialUIOptions]::ValidateUserNameSyntax

$Host.UI.PromptForCredential($PromptCaption,$PromptMessage,"","",$CredentialType,$ValidateOption)

enter image description here

+2
source

All Articles