Can't Load PowerCLI Module

Setting up a Powershell script that will load the PowerCLI module. It works fine from the Orion server, but when tested in the Powershell Monitor it refuses to load:

Import-Module : The specified module 'VMware.VimAutomation.Core' was not loaded because no valid module file was found in any module directory.

I've tried switching the polling to x64 and x86 with no luck. I've got PowerCLI 6.5 and Powershell 5.1 installed on the Orion server. I've also verified the PsModulePath has the directory. Not sure what I'm doing wrong here. I've opened a support case as well.

Any help would be appreciated!

Parents
  • Is the script set to remote execution or local?  Does the node in question have the agent installed?

  • It is set to local and connecting to a vCenter server. No agent. Just trying to get a statistic. Passing ${Node.DNS} as the argument for the $esxhost variable. Here's the script (sensitive data changed)

    Import-Module VMware.VimAutomation.Core

    Connect-VIServer -Server vcenter1 -User someuser -Password "password" | Out-Null

    $esxhost = $args[0]

    $start = (get-date).AddMinutes(-15)

    $ReadLatency = Get-Stat -Entity $esxhost -Realtime -Stat "datastore.totalReadLatency.average" -Start $start -MaxSamples ([int]::MaxValue) -Instance "*" |  select Value -First 1

    $stat = $ReadLatency.Value

    write-host "Message: Average Read Latency"

    write-host "Statistic: $stat"

    exit 0;

Reply
  • It is set to local and connecting to a vCenter server. No agent. Just trying to get a statistic. Passing ${Node.DNS} as the argument for the $esxhost variable. Here's the script (sensitive data changed)

    Import-Module VMware.VimAutomation.Core

    Connect-VIServer -Server vcenter1 -User someuser -Password "password" | Out-Null

    $esxhost = $args[0]

    $start = (get-date).AddMinutes(-15)

    $ReadLatency = Get-Stat -Entity $esxhost -Realtime -Stat "datastore.totalReadLatency.average" -Start $start -MaxSamples ([int]::MaxValue) -Instance "*" |  select Value -First 1

    $stat = $ReadLatency.Value

    write-host "Message: Average Read Latency"

    write-host "Statistic: $stat"

    exit 0;

Children
  • So just to verify that Orion is doing what you expect.  Lets do some debugging:

    1) Add another statistic for debugging

    write-host "Message.readlatency: Average Read Latency"

    write-host "Statistic.readlatency: $stat"

    write-host "Message.debug1: Server:$(hostname) User:$(whoami)"

    write-host "Statistic.debug1: 0"

    exit 0;

    2) The server should be the orion polling engine you have the node assigned to.

    3) The user should be what you have specified on "Credential for Monitoring" on the component.

    4) If everything so far is what you expect, then remote to the orion server, and run powershell as that user.  If you have the option to remote desktop as the specified user then great, otherwise you have to <shift>right-click on the powershell icon to get "Run as different user".

    5) Once you are in powershell as that user, run "whoami" just to make sure. 

    6) run "get-module" to see if your VMware.VimAutomation.Core is there.

    7) let us know where you are at and we can continue from there.

  • Since the module won't load, this won't work.

    Same user runs many other scripts

    The script can be run on Orion server in Powershell as the user with no issue

    Module is in the PSModule path

    Module is available when running get-module -ListAvailable. When testing the monitor, it errors on loading it;

    Errors: ==============================================

    Import-Module : The specified module 'VMware.VimAutomation.Core' was not loaded because no valid module file was found in any module directory.

    At line:1 char:1

    + Import-Module VMware.VimAutomation.Core

    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~