VMware Cloud Community
jeffdoliver
Enthusiast
Enthusiast
Jump to solution

Issue with PowerCLI 13.1 and Windows PowerShell 5.1

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!

Reply
0 Kudos
1 Solution

Accepted Solutions
jeffdoliver
Enthusiast
Enthusiast
Jump to solution

@LucD, I figured it out!  It was the .NET Framework version.  As noted in my OP, it was 4.7.2053 and I just now upgraded to 4.8.3761.  After doing so, it works perfectly.  Strange, since the Compatibility Matrix indicates that 4.7.2 is sufficient.  Oh well, glad it's working now!  Thanks for your help!

View solution in original post

Reply
0 Kudos
12 Replies
LucD
Leadership
Leadership
Jump to solution

Do you have multiple PowerCLI versions installed?
Do a

Get-Module -Name VMware* -ListAvailable

You could try to remove all PowerCLI folders you find via the above command and then do a fresh install from scratch

Install-Module -Name VMware.PowerCLI

 
PS: PowerCLI 13.1 is working fine with PSv5.1 in all my installations


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

Reply
0 Kudos
jeffdoliver
Enthusiast
Enthusiast
Jump to solution

I'm pretty sure they're all removed.  I went into every folder that's in my $env:psmodulepath, and verified that none exist.  Then I copied the unzipped files from the 13.1 zip into one of those directories.  My system is not connected to the internet, so I have to do the offline method.  I made sure to follow your instructions from a past thread and use 'Get-ChildItem -Recurse | Unblock-File'.

Here's the output of the command 'Get-Module -Name VMware* -ListAvailable':

ModuleType Version           Name
---------- -------           ----
    Script 12.6.0.19606210   VMware.CloudServices
    Script 8.0.0.21610665    VMware.DeployAutomation
    Script 8.0.0.21610262    VMware.ImageBuilder
  Manifest 13.1.0.21624340   VMware.PowerCLI
    Script 12.6.0.19600125   VMware.PowerCLI.Sdk
    Script 12.6.0.19600125   VMware.PowerCLI.Sdk.Types
    Script 12.6.0.19600125   VMware.PowerCLI.VCenter
    Script 12.6.0.19600125   VMware.PowerCLI.VCenter.Types.ApplianceService
    Script 12.6.0.19600125   VMware.PowerCLI.VCenter.Types.CertificateManagement
    Script 4.1.0.21605558    VMware.Sdk.Nsx.Policy
    Script 1.0.1111.21624264 VMware.Sdk.Runtime
    Script 8.7.0.21605564    VMware.Sdk.Srm
    Script 8.7.0.21605566    VMware.Sdk.Vr
  Manifest 8.0.1111.21624264 VMware.Sdk.vSphere
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.Appliance
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.Appliance.Access
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.Appliance.Health
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.Appliance.InfraProfile
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.Appliance.LocalAccounts
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.Appliance.Logging
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.Appliance.Networking
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.Appliance.Recovery
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.Appliance.SupportBundle
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.Appliance.System
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.Appliance.Update
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.Cis
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.Cis.Tagging
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.Content
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.ContentLibrary
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.Esx.Hcl
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.Esx.Hosts
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.Esx.Settings
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.VAPI.Metadata
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter.Authentication
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter.Authorization
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter.CertManagement
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter.ConsumptionDomains
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter.Content
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter.Datastore
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter.Deployment
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter.Guest
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter.hvc
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter.Identity
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter.Inventory
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter.ISO
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter.LCM
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter.NamespaceManagement
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter.Namespaces
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter.OVF
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter.Services
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter.Storage
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter.SystemConfig
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter.Tagging
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter.Topology
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter.TrustedInfrastructure
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter.VCHA
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter.Vm
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vCenter.VmTemplate
    Script 8.0.1111.21624264 VMware.Sdk.vSphere.vStats
    Script 8.0.1111.21624264 VMware.Sdk.vSphereRuntime
    Script 8.1.0.21605554    VMware.Vim
    Script 13.1.0.21605976   VMware.VimAutomation.Cis.Core
    Script 13.1.0.21611174   VMware.VimAutomation.Cloud
    Script 13.1.0.21605386   VMware.VimAutomation.Common
    Script 13.1.0.21606170   VMware.VimAutomation.Core
    Script 13.0.0.20803747   VMware.VimAutomation.Hcx
    Script 13.1.0.21610272   VMware.VimAutomation.HorizonView
    Script 12.0.0.15939670   VMware.VimAutomation.License
    Script 13.1.0.21606089   VMware.VimAutomation.Nsxt
    Script 13.1.0.21605170   VMware.VimAutomation.Sdk
    Script 13.1.0.21606510   VMware.VimAutomation.Security
    Script 12.7.0.20091290   VMware.VimAutomation.Srm
    Script 13.1.0.21606282   VMware.VimAutomation.Storage
    Script 1.6.0.0           VMware.VimAutomation.StorageUtility
    Script 13.1.0.21610933   VMware.VimAutomation.Vds
    Script 13.0.0.20797723   VMware.VimAutomation.Vmc
    Script 13.1.0.21611158   VMware.VimAutomation.vROps
    Script 12.4.0.18627055   VMware.VimAutomation.WorkloadManagement
    Script 12.7.0.20091294   VMware.VumAutomation

 Thanks!

Reply
0 Kudos
jeffdoliver
Enthusiast
Enthusiast
Jump to solution

Confirmed:  When I remove the VMware Modules from the folder, then run

Get-Module -Name VMware* -ListAvailable

nothing shows up.

Maybe it's the zip file?  I did redownload it (in case it was a corrupted file), and even tried unblocking it before unzipping, but same result.

I'll try following PowerCLI Offline Installation Walkthrough and see if the 'Save-Module' method works.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Are you installing it on an isolated station?
Otherwise an Install-Module is much easier


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

Reply
0 Kudos
jeffdoliver
Enthusiast
Enthusiast
Jump to solution

Yes, the system is isolated (no internet access).  I used Save-Module / Install-Module on another machine with internet access, then copied over the VMware* modules.  Same exact behavior as before, so that rules out a corrupted ZIP.

Any ideas?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Did you install the PowerCLI folders in a folder that is listed in $env:PSModulePath


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

Tags (1)
Reply
0 Kudos
jeffdoliver
Enthusiast
Enthusiast
Jump to solution

Yes.

PS C:\Users\user> $env:PSModulePath
C:\Users\user\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;D:\Program Files (x86)\Cisco\Cisco UCS PowerTool\Modules\;C:\Program Files\Microsoft System Center\Virtual Machine Manager\bin\psModules\;g:\psmodules;C:\Program Files\System Center Operations Manager\Powershell\;C:\Program Files\System Center Operations Manager\Powershell\;C:\Program Files\Hewlett-Packard\PowerShell\Modules\HPiLOCmdlets;C:\Program Files (x86)\WindowsPowerShell\Modules\;C:\Program Files\PowerShell\7\Modules

I put them in the following directory:

PS C:\Program Files\WindowsPowerShell\Modules> dir VMware*
    Directory: C:\Program Files\WindowsPowerShell\Modules
Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        7/13/2023   3:32 PM                VMware.CloudServices
d-----        7/13/2023   3:33 PM                VMware.DeployAutomation
d-----        7/13/2023   3:33 PM                VMware.ImageBuilder
d-----        7/13/2023   3:33 PM                VMware.PowerCLI
d-----        7/13/2023   3:33 PM                VMware.PowerCLI.Sdk
d-----        7/13/2023   3:33 PM                VMware.PowerCLI.Sdk.Types
d-----        7/13/2023   3:33 PM                VMware.PowerCLI.VCenter
d-----        7/13/2023   3:33 PM                VMware.PowerCLI.VCenter.Types.ApplianceService
d-----        7/13/2023   3:33 PM                VMware.PowerCLI.VCenter.Types.CertificateManagement
d-----        7/13/2023   3:33 PM                VMware.Sdk.Nsx.Policy
d-----        7/13/2023   3:34 PM                VMware.Sdk.Runtime
d-----        7/13/2023   3:34 PM                VMware.Sdk.Srm
d-----        7/13/2023   3:34 PM                VMware.Sdk.Vr
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.Appliance
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.Appliance.Access
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.Appliance.Health
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.Appliance.InfraProfile
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.Appliance.LocalAccounts
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.Appliance.Logging
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.Appliance.Networking
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.Appliance.Recovery
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.Appliance.SupportBundle
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.Appliance.System
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.Appliance.Update
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.Cis
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.Cis.Tagging
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.Content
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.ContentLibrary
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.Esx.Hcl
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.Esx.Hosts
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.Esx.Settings
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.VAPI.Metadata
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter.Authentication
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter.Authorization
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter.CertManagement
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter.ConsumptionDomains
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter.Content
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter.Datastore
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter.Deployment
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter.Guest
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter.HVC
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter.Identity
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter.Inventory
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter.ISO
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter.LCM
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter.NamespaceManagement
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter.Namespaces
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter.OVF
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter.Services
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter.Storage
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter.SystemConfig
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter.Tagging
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter.Topology
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter.TrustedInfrastructure
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter.VCHA
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter.Vm
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vCenter.VmTemplate
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphere.vStats
d-----        7/13/2023   3:34 PM                VMware.Sdk.vSphereRuntime
d-----        7/13/2023   3:34 PM                VMware.Vim
d-----        7/13/2023   3:34 PM                VMware.VimAutomation.Cis.Core
d-----        7/13/2023   3:34 PM                VMware.VimAutomation.Cloud
d-----        7/13/2023   3:35 PM                VMware.VimAutomation.Common
d-----        7/13/2023   3:35 PM                VMware.VimAutomation.Core
d-----        7/13/2023   3:35 PM                VMware.VimAutomation.Hcx
d-----        7/13/2023   3:35 PM                VMware.VimAutomation.HorizonView
d-----        7/13/2023   3:35 PM                VMware.VimAutomation.License
d-----        7/13/2023   3:35 PM                VMware.VimAutomation.Nsxt
d-----        7/13/2023   3:35 PM                VMware.VimAutomation.Sdk
d-----        7/13/2023   3:35 PM                VMware.VimAutomation.Security
d-----        7/13/2023   3:35 PM                VMware.VimAutomation.Srm
d-----        7/13/2023   3:35 PM                VMware.VimAutomation.Storage
d-----        7/13/2023   3:36 PM                VMware.VimAutomation.StorageUtility
d-----        7/13/2023   3:36 PM                VMware.VimAutomation.Vds
d-----        7/13/2023   3:36 PM                VMware.VimAutomation.Vmc
d-----        7/13/2023   3:36 PM                VMware.VimAutomation.vROps
d-----        7/13/2023   3:36 PM                VMware.VimAutomation.WorkloadManagement
d-----        7/13/2023   3:36 PM                VMware.VumAutomation

 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You did check that the structure for each of those folders is like this

LucD_0-1689354184395.png

 


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

Reply
0 Kudos
jeffdoliver
Enthusiast
Enthusiast
Jump to solution

Yes, though my 'VMware.VimAutomation.Core' does have two folders in it:

  • 6.5.2.6234650
  • 13.1.0.21606170

Otherwise, the structure is the same.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

That would indicate you still have 2 versions installed.
Did you manually delete all the PowerCLI folders before copying the ones from the Save-Module file?


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

Reply
0 Kudos
jeffdoliver
Enthusiast
Enthusiast
Jump to solution

I did.  I wonder if they came from the source server where I copied them.  I deleted the earlier version, then went through ever folder and made sure there was only one version subfolder.  Same behavior as before.

I removed them all again and copied the files over from the ZIP (from the VMware Download Site) and noticed that there are no version subfolders.  This must be something that gets done by 'Save-Module' / 'Install-Module'.  Still, same behavior as before.

Reply
0 Kudos
jeffdoliver
Enthusiast
Enthusiast
Jump to solution

@LucD, I figured it out!  It was the .NET Framework version.  As noted in my OP, it was 4.7.2053 and I just now upgraded to 4.8.3761.  After doing so, it works perfectly.  Strange, since the Compatibility Matrix indicates that 4.7.2 is sufficient.  Oh well, glad it's working now!  Thanks for your help!

Reply
0 Kudos