I recently upgraded from PowerCLI 12.7 to 13.1 to gain additional support for vSphere 8.0. However, after doing so, I'm unable to properly connect to any vCenters via Windows PowerShell 5.1.
When I enter
Connect-VIServer <vcenter name>
It returns with an error:
Connect-VIServer : The 'Connect-VIServer' command was found in the module 'VMware.VimAutomation.Core', but the module could not be loaded. For more information, run 'Import-Module VMware.VimAutomation.Core'.
At line:1 char:1
+ Connect-VIServer <vcenter name>
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Connect-VIServer:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
If I then try to run 'Import-Module VMware.VimAutomation.Core', it is successful and lets me run the command. However, it prompts me for credentials instead of passing through my Windows Credentials like normal. When I enter the correct credentials (in all three formats: user, domain/user, user@domain.net), it fails with a certificate error:
Connect-VIServer : 7/11/2023 9:48:30 AM Connect-VIServer An error occurred while making the HTTP request to https://<vcenter name>.<domain>.net/sdk. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS
in the HTTPS
case. This could also be caused by a mismatch of the security binding between the client and the server.
At line:1 char:1
+ Connect-VIServer <vcenter name>.<domain>.net
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Connect-VIServer], ViError
+ FullyQualifiedErrorId : Client20_ConnectivityServiceImpl_Reconnect_SoapException,VMware.VimAutomation.ViCore.Cmdlets.Commands.ConnectVIServer
However, if I open PowerShell 7, I am able to run the command perfectly and connect with passthrough authentication, as long as I use the FQDN (not something I had to do in previous versions). I'm confused why the same won't work for Windows PowerShell 5.1. I removed all the previous VMware* modules from ALL $env:PSModulePath folders. I am placing the new 13.1 modules in 'C:\Program Files\WindowsPowerShell\Modules'.
One additional scenario to note; If I run the command 'Import-Module VMware.VimAutomation.Core' in a fresh session, I get the following error:
Import-Module : VMware PowerCLI on Windows PowerShell requires .Net Framework version 4.7.2 or higher.
At line:1 char:1
+ Import-Module VMware.VimAutomation.Core
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (VMware PowerCLI....7.2 or higher.:String) [Import-Module], RuntimeException
+ FullyQualifiedErrorId : VMware PowerCLI on Windows PowerShell requires .Net Framework version 4.7.2 or higher.,Microsoft.PowerShell.Commands.ImportModuleCommand
Strangely, if I run the same command again, it takes a few seconds, then appears to work without error. However I still can't connect to a vCenter (same issues as above).
Here are my versions:
- Windows PowerShell: 5.1.14393.5582
- PowerShell: 7.3.4
- Windows 2016: 10.0.14393
- Microsoft .NET: 4.7.02053
Thanks in advance for any assistance!