#Problems with PowerCLI

1 messages · Page 1 of 1 (latest)

rain bolt
#

Hi everyone,

I’m running into a problem with PowerCLI at work.

We run PowerShell as a Citrix Icon. When a user launches it, it starts a fresh PowerShell session, installs a bunch of modules (including PowerCLI), sets proxy settings, etc. Basically, a big initialization script that sets up everything for them. To my knowledge, the Citrix servers already have PowerCLI installed beforehand, maybe updated by SCCM? 🤷‍♂️

The issue is that for some reason today PowerCLI got completely borked. I’m not a PowerCLI expert myself, and all the people who are know this stuff well are on their summer holidays…

It looks like there’s some sort of version mismatch between VMware.Vim and VMware.VimAutomation.Core. When the script runs, it fails to import VMware.VimAutomation.Core because it says VMware.Vim isn’t loaded.

Here’s what I’m seeing:

Import-Module: \\domain.corp\dfs\AppData\Powershell\powershell-script.ps1:68
Line |
  68 |      Import-Module -name VMware.VimAutomation.Core
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The required module 'VMware.Vim' is not loaded. Load the module or remove the module from 'RequiredModules' in the file
     | 'C:\Users\user\Documents\PowerShell\Modules\VMware.OpenAPI\13.4.0.24798382\VMware.OpenAPI.psd1'.

I checked Get-Module -ListAvailable and found multiple versions of both modules:

[]PS>Get-Module -Name VMware.VimAutomation.Core, VMware.Vim -ListAvailable | ft -AutoSize
 
    Directory: C:\Users\user\Documents\PowerShell\Modules
 
ModuleType Version         PreRelease Name                      PSEdition ExportedCommands
---------- -------         ---------- ----                      --------- ----------------
Script     13.4.0.24798382            VMware.VimAutomation.Core Desk      {Add-PassthroughDevice, Add-VirtualSwitchPhysicalNetworkAdapter, Add-VITrustedCertificate, Add-VMHost…}
 
    Directory: C:\Program Files\WindowsPowerShell\Modules
 
ModuleType Version         PreRelease Name                      PSEdition ExportedCommands
---------- -------         ---------- ----                      --------- ----------------
Script     8.3.0.24145081             VMware.Vim                Desk
Script     8.2.0.22643731             VMware.Vim                Desk
Script     8.1.0.21605554             VMware.Vim                Desk
Script     8.0.1.20797199             VMware.Vim                Desk
Script     7.0.3.19601056             VMware.Vim                Desk
Script     13.3.0.24145081            VMware.VimAutomation.Core Desk      {Add-PassthroughDevice, Add-VirtualSwitchPhysicalNetworkAdapter, Add-VMHost, Add-VMHostNtpServer…}
Script     13.2.0.22643732            VMware.VimAutomation.Core Desk      {Add-PassthroughDevice, Add-VirtualSwitchPhysicalNetworkAdapter, Add-VMHost, Add-VMHostNtpServer…}
Script     13.1.0.21606170            VMware.VimAutomation.Core Desk      {Add-PassthroughDevice, Add-VirtualSwitchPhysicalNetworkAdapter, Add-VMHost, Add-VMHostNtpServer…}
Script     13.0.0.20797821            VMware.VimAutomation.Core Desk      {Add-PassthroughDevice, Add-VirtualSwitchPhysicalNetworkAdapter, Add-VMHost, Add-VMHostNtpServer…}
Script     12.7.0.20091293            VMware.VimAutomation.Core Desk      {Add-PassthroughDevice, Add-VirtualSwitchPhysicalNetworkAdapter, Add-VMHost, Add-VMHostNtpServer…}

If I try manually:

Import-Module -Name VMware.Vim
Import-Module -Name VMware.VimAutomation.Core

I still get:

Import-Module: The required module 'VMware.Vim' is not loaded. Load the module or remove the module from 'RequiredModules' in the file 'C:\Users\user\Documents\PowerShell\Modules\VMware.OpenAPI\13.4.0.24798382\VMware.OpenAPI.psd1'.

Any tips to untangle this mess would be super appreciated 🙏

elfin birch
#

Version 13.4.0.24798382 of VMware.VimAutomation.Core ultimately requires VMware.Vim greater or equal to 9.0.0.24798382 which you do not appear to have.

Delete all extraneous versions you don't plan to use. Delete all random copies of modules from other paths where you have no intention of using them.

There's a really strong argument for not ever pulling content from the gallery on the fly in this. A curated known-working set of modules is much better for you.

Then it's a manageable process to update and test your curated content as needed.

rain bolt
elfin birch
#

In the PS gallery, package info. You should also be able to see in the output from Get-Module, but iirc you have to dig a little more to see it

rain bolt