5 Replies Latest reply on Jan 10, 2020 10:34 AM by t0ta11ed74

    Can't Load PowerCLI Module

    t0ta11ed74

      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!

        • Re: Can't Load PowerCLI Module
          mesverrum

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

            • Re: Can't Load PowerCLI Module
              t0ta11ed74

              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;

                • Re: Can't Load PowerCLI Module
                  brscott@arcbtech.com

                  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.

                    • Re: Can't Load PowerCLI Module
                      t0ta11ed74

                      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

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

                • Re: Can't Load PowerCLI Module
                  t0ta11ed74

                  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.