VMware Cloud Community
PGinhoux
Enthusiast
Enthusiast
Jump to solution

Connect-CisServer failure to convert the password

Hi,

I wanted to use the Backup-VCSA script from Brian Graf to schedule a periodic backup of my vCSA.

So that I started to created a .ps1 script to set up different variables as follows:

$ServerAddress = "<vCSA IP address>"
$User = "<User account to connect the vCSA"
[VMware.VimAutomation.Cis.Core.Types.V1.Secret]$Pass = "<Password for the account>"
Connect-CisServer -Server $serverAddress -User $User -Password $Pass

But the Connect-CisServer command fails with the following error :

Connect-CisServer : Cannot bind parameter 'Password'. Cannot convert the "<secret>" value of type "VMware.VimAutomation.Cis.Core.Types.V1.Secret" to type

"System.Security.SecureString".

At C:\temp\Test-BackupVCSA-3.ps1:4 char:64

+ Connect-CisServer -Server $serverAddress -User $User -Password $Pass

+                                                                ~~~~~

    + CategoryInfo          : InvalidArgument: (:) [Connect-CisServer], ParameterBindingException

    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,VMware.VimAutomation.Cis.Core.Commands.Cmdlets.ConnectCisServer

I run the following version :

Name                           Value                                                                                                                                              

----                           -----                                                                                                                                              

PSVersion                      5.1.14409.1005                                                                                                                                     

PSEdition                      Desktop                                                                                                                                            

PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                            

BuildVersion                   10.0.14409.1005                                                                                                                                    

CLRVersion                     4.0.30319.42000                                                                                                                                    

WSManStackVersion              3.0                                                                                                                                                

PSRemotingProtocolVersion      2.3                                                                                                                                                

SerializationVersion           1.1.0.1      

And I run also the VMware 6.5 on my vCSA and hosts as well.

Any thoughts about this error ?

Thanks in advance for the answers.

Regards

Patrick

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Why the type-casting on the password?

Just a [string] will doversion

PS: I would strongly advise to upgrade your PowerCLI

$ServerAddress = "<vCSA IP address>"

$User = "<User account to connect the vCSA"

$Pass = "<Password for the account>"

Connect-CisServer -Server $serverAddress -User $User -Password $Pass


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
11 Replies
LucD
Leadership
Leadership
Jump to solution

Why the type-casting on the password?

Just a [string] will doversion

PS: I would strongly advise to upgrade your PowerCLI

$ServerAddress = "<vCSA IP address>"

$User = "<User account to connect the vCSA"

$Pass = "<Password for the account>"

Connect-CisServer -Server $serverAddress -User $User -Password $Pass


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
PGinhoux
Enthusiast
Enthusiast
Jump to solution

Hi,

Actually, in my research of scripts to automate the vCSA back, I had found those from Brian Graf in which he used this method on the password.

I'm not so experimented in this so I thought it was the way it should be done.

Now if it could be simplified that's ok for me.

About my PowerCLI, I thought I had the most recent version  but i'll check that again.

Thanks for the help.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Just do a

Get-Module -Name VMware* -ListAvailable | Select Name,Version


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
PGinhoux
Enthusiast
Enthusiast
Jump to solution

Hereafter the result:

Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

PS C:\Users\NIUAdmin> Get-Module -Name VMware* -ListAvailable | Select Name,Version

Name                                Version
----                                -------
VMware.DeployAutomation             6.5.2.7812840
VMware.ImageBuilder                 6.5.2.7812840
VMware.PowerCLI                     10.0.0.7895300
VMware.VimAutomation.Cis.Core       10.0.0.7893915
VMware.VimAutomation.Cloud          10.0.0.7893901
VMware.VimAutomation.Common         10.0.0.7893906
VMware.VimAutomation.Core           10.0.0.7893909
VMware.VimAutomation.HA             6.5.4.7567193
VMware.VimAutomation.HorizonView    7.1.0.7547311
VMware.VimAutomation.License        10.0.0.7893904
VMware.VimAutomation.Nsxt           10.0.0.7893913
VMware.VimAutomation.PCloud         10.0.0.7893924
VMware.VimAutomation.Sdk            10.0.0.7893910
VMware.VimAutomation.Srm            10.0.0.7893900
VMware.VimAutomation.Storage        10.0.0.7894167
VMware.VimAutomation.StorageUtility 1.2.0.0
VMware.VimAutomation.Vds            10.0.0.7893903
VMware.VimAutomation.Vmc            10.0.0.7893902
VMware.VimAutomation.vROps          10.0.0.7893921
VMware.VumAutomation                6.5.1.7862888

PS C:\Users\NIUAdmin>

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Ok, I read the wrong it seems, this indeed a very recent release.

Did the connect work when you left out the type-casting?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
PGinhoux
Enthusiast
Enthusiast
Jump to solution

Yes the connect works without the type-casting, but it takes more than 2 minutes to connect.

Do you know what could be the reason for this delay?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

No, not really.
In my environment it's a bit slower than the Connect-VIServer, but still it's seconds, not minutes.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
PGinhoux
Enthusiast
Enthusiast
Jump to solution

Well it's not a big deal as it is for batch request to backup the vCSA.

So for the moment I don't really need more.

Thanks Luc for the help.

Reply
0 Kudos
AdmLAS
Contributor
Contributor
Jump to solution

Script working good :

$FilePath = "\\Path\Crypt"
$File = "$FilePath\crypt-Password-.txt"
$User = "administrator"
$Credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, (Get-Content $File | ConvertTo-SecureString)

Connect-CIServer -Server <NameServer> -Credential $Credential

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Just a quick remark, Connect-CiServer and Connect-CisServer are not the same.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
AdmLAS
Contributor
Contributor
Jump to solution

Indeed, sorry i did not see the "s".

 

I try the command and it's possible and it's work too 😉

Reply
0 Kudos