mcarrillo01
VMware Employee
VMware Employee

Not able to connect to vCenter via powerCLI

PowerShell: 5.1.17763.1007

PowerCLI: 11.5.0.14912921

.Net Framework: 4.7.2 release 461814

- Not able to connect to vCenter via powerCLI

- Get the following error:

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'.

- If we run an "Import-Module VMware.VimAutomation.Core" we get the following:

import-module the specified module 'vmware.vimautomation.core' was not loaded because no valid module file was found in any module directory

- We can confirm that all folders and files exist under c:\Program Files\WindowsPowerShell\Modules but it seems that the version is under 12.0.0 which was deleted previously

- We also tried version 12.0 but when trying to connect it gives the following error:

The term 'Connect-VIServer' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Screenshots attached

0 Kudos
5 Replies
jburen
Expert
Expert

I think that for some reason your PowerCLI install got messed up. The manifest file is from an older version. I would suggest removing all PowerCLI modules and reinstall from scratch. The module folders are directly in the C:\Program Files\WindowsPowerShell\Modules folder so there is no version subfolder.

Consider giving Kudos if you think my response helped you in any way.
0 Kudos
scott28tt
VMware Employee
VMware Employee

Moderator: Moved to PowerCLI Discussions

0 Kudos
LucD
Leadership
Leadership

First do a Get-Module -Name VMware* to find out what you have installed and where.
The PowerCLI modules do have a version number, it is under the VMware.VimAutomation folders.

Once you have the folders, remove them manually.

Then, from a PS session, do an Install-Module -Name VMware.PowerCLI.

More details can be found in Welcome PowerCLI to the PowerShell Gallery – Install Process Updates


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

0 Kudos
jburen
Expert
Expert

Luc, should you have the version folders with an offline installation? I did an offline installation of PowerCLI (according to https://blogs.vmware.com/PowerCLI/2018/01/powercli-offline-installation-walkthrough.html) and I don't have any version folders whatsoever. The blog even references a script that removes those folders: The script simply looks for the folders that already exist in any of the PSModulePath listed directories, searching specifically for PowerCLI module folders, and then removes that additional nested level of version-based folders.

Consider giving Kudos if you think my response helped you in any way.
0 Kudos
LucD
Leadership
Leadership

No, when using the offline installation, there are indeed no module versions.
That is because that package is created for PSv4.

A better method, imho, for an offline installation, is to do the Save-Module yourself from a PSv5 session.
Provided you are targeting a PSv5 platform of course.
In general, do the Save-Module from the same PS version you are targetting.


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