Hi everyone, I just want to validate a behavior that I experience here.
I am using PowerCli version 11.3.0.13964826 and when trying to pass credential that way:
$Cred = Get-Credential -Message "Try AA123456@test.com, Dev and QA AA123456"
Connect-VIServer -Server myserver -user $Cred.Username -password $Cred.Password
I get an error Cannot complete login due to an incorrect user name or password.
But using that way:
$Cred = Get-Credential
Connect-VIServer -Server myserver -user $Cred.Username -password $Cred.Password
I can connect without any error message.
Any idea of what is not working here. And when I am showing the content of the variables, the content is the same in both case.
Thank you!
Mathieu
The Password property in the $Cred variable is a SecureString, while the -Password parameter on Connect-VIServer expects a string.
There are 2 options
Connect-VIServer -Server myserver -Credential $Cred
Connect-VIServer -Server myserver -User $Cred.UserName -Password $Cred.GetNetworkCredential().Password
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The Password property in the $Cred variable is a SecureString, while the -Password parameter on Connect-VIServer expects a string.
There are 2 options
Connect-VIServer -Server myserver -Credential $Cred
Connect-VIServer -Server myserver -User $Cred.UserName -Password $Cred.GetNetworkCredential().Password
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Really strange because before adding the -Message I was using the same syntax to connect and it was working but indeed, using -Credential with Connect-VIServer seem to fix my issue.
Thank you!