I rung the following command inside powercli 5.5:-

PowerCLI C:\> Connect-VIServer -Server -User root -Password ****

but I got a dialog to enter username and password although I am supplying the username & password in the script -User & -Password? so can anyone advice why powercli is not recognizing these parameters ?


I believe the User and Password parameters have been deprecated in the newest versions of PowerCLI. Use -Credential with a pscredential object instead:

$Username = 'root'
$Password = 'Sup4hS3cuRe' | ConvertTo-SecureString -AsPlainText -Force
$Credential = New-Object -TypeName pscredential -ArgumentList $Username,$Password

Connect-VIServer -Server -Credential $Credential
| improve this answer | |
  • not sure how did it work but I just surrounded the password with " " and I can connect without being prompted with a dialog ... – John John Aug 5 '15 at 12:05
  • @JohnJohn Cool, if that's your solution, add an answer yourself :) – Mathias R. Jessen Aug 5 '15 at 12:21
  • I think your script is better and more secure, but when I run your script I got the following error :- New-Object : Cannot find type [pscredential]: make sure the assembly containing this type is loaded. At line:1 char:25 + $Credential = New-Object <<<< -TypeName pscredential -ArgumentList $Username ,$Password + CategoryInfo : InvalidType: (:) [New-Object], PSArgumentExcepti on + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewOb jectCommand – John John Aug 5 '15 at 13:06
  • @Mathiase I am using power shell 5.5 release 1. can you advice on this please? – John John Aug 5 '15 at 13:06
  • @JohnJohn try substituting pscredential with the full type name System.Management.Automation.PSCredential – Mathias R. Jessen Aug 5 '15 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.