Connect-VIServer doesn't connect due to invalid certificate disregarding PowerCLI's configuration
Asked Answered
C

1

6

As the title suggests, I'm trying to login to a VMWare vSphere server using PowerCLI. Even though I ran Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false -Scope AllUsers, when I try to connect to the server this is what I'm getting:

Connect-VIServer -Server "foobar.server" -User ... -Password ...
Connect-VIServer : 3/30/2020 4:16:46 PM Connect-VIServer                Error: Invalid server certificate. Use Set-PowerCLIConfiguration to set the value for the InvalidCertificateAction option to Prompt if you'd like to connect once or to add a permanent exception for this server.
Additional Information: Could not establish secure channel for SSL/TLS with authority 'foobar.server'.
At line:1 char:1
+ Connect-VIServer -Server "foobar.server" -User ... -Passw ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [Connect-VIServer], ViSecurityNegotiationException
    + FullyQualifiedErrorId : Client20_ConnectivityServiceImpl_Reconnect_CertificateError,VMware.VimAutomation.ViCore.Cmdlets.Commands.ConnectVIServer

It seems like the configuration took:

Get-PowerCLIConfiguration

Scope    ProxyPolicy     DefaultVIServerMode InvalidCertificateAction  DisplayDeprecationWarnings WebOperationTimeout
                                                                                                  Seconds
-----    -----------     ------------------- ------------------------  -------------------------- -------------------
Session  UseSystemProxy  Multiple            Ignore                    True                       300
User                                         Ignore
AllUsers                                     Ignore

Why can't I connect to the server?

Cristal answered 30/3, 2020 at 13:24 Comment(2)
Did you restart PowerCLI after making the change?Sherrod
@Sherrod what do you mean by restarting PowerCLI? I'm planning to use this in a script eventually...Cristal
M
3

if you are using an older version of vCenter (5.5) try this:

[System.Net.ServicePointManager]::SecurityProtocol =[System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
Misdate answered 1/4, 2020 at 8:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.