This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

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!

  • 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;

  • Opened a case with Support on 11/27. Been back and forth for about the last month, and the assigned tech doesn't seem to understand what the issue is really. Waiting long periods while they "get with enginering". Last response was they were trying to tell me they don't provide support for scripts, which is not what the case was opened for. I have to say, Support has gotten horrible in the last few years.

  • 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

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

  • I know this is an old post. But I wanted to share that recently, I had issues with modules in a script action for an alert. For some bizarre reason, PowerShell was not finding modules in the default location. I added this as one of the first lines of the script, and it solved the problem:

    $env:PsModulePath += ';C:\Program Files\WindowsPowerShell\Modules'

  • I'm having exactly the same problem trying to load SwisPowerShell but this didn't help unfortunately.