MarkD
MarkD

Reputation: 11

Connect-VIServer failed

Trying to automate the connection to VCenter with a rundeck Job. The powershell script works within powershell when I use it; however, It fails to run properly when used with rundeck. The script is:

if(-not (Get-Module -Name VMware.PowerCLI -ListAvailable)){
    Install-Module -Name VMware.PowerCLI -AllowClobber -Force -Confirm:$false
}
Connect-VIServer -Server $ipaddr -User $usrnme -Password $pswd
Get-VM $vm | Select-Object @{N="IP Address";E={@($_.guest.IPAddress[0])}}

The error I see in rundeck is a simple Connect-ViServer The ssl connection could not be established, see inner exception

Upvotes: 0

Views: 4777

Answers (2)

River Bee
River Bee

Reputation: 11

This resolved the error Connect-VIServer The SSL connection could not be established, see inner exception running PowerCLI 12.4 and Powershell 7.2.1.

Connect-VIServer -Server $ipaddr -User $usrnme -Password $pswd

Adding -Force to the end

Connect-VIServer -Server $ipaddr -User $usrnme -Password $pswd -Force

Upvotes: 1

MarkD
MarkD

Reputation: 11

I fixed the issue by adding the parameter -Force

To the end of the line containing:

Connect-VIServer -Server $ipaddr -User $usrnme -Password $pswd   
Get-VM $vm | Select-Object @{N="IP Address";E={@($_.guest.IPAddress[0])}}

Upvotes: 1

Related Questions