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.

PowerCLI VMWare - PowerShell

I want tho monitoring my ESXi-Servers, but I can't import the PowerCLI-Module installed on the Orion Server using Powershell, using SolarWinds SAM.

If I enter this command in a new SAM-Template, I become an error (Impossible load the Snaping):

Add-PSSnapin VMware.VimAutomation.Core;

Can you help me solve this problem?

Thank you very much

mirkoo1994

  • What's the actual error? Can you paste it? Or even a screen shot? Where do you see it? Can you do the same thing from the server running SAM without issues?

  • Hi Jonathan

    First, thank you very much for replying my question.

    So this is a part of  my PowerShell-Code in the SAM:

    printscreen.PNG

    This code should  Retourn me the current datastore of the ESXi-Server, but I receive the Error, that I am not connected to any Server.

    I also become a Certificate-Error WARNING after connecting to the ESXi.

    I can run this command on the Orion Server without any issues.

    So thank you very much again for the support! I would be happy if you could help me.

    Mirko Lanfrachi

  • I have had issues using add-pssnapin before (could be a 1 off) and had success with Import-Module

  • I also become this error, when i try to connect to the server:

    test.PNG

    For ignoring the Certificate I entered "-WarningAction SilentlyContinue" in the code.

    Only FYI! emoticons_happy.png

    Thank you very much.

    Bests

    Mirko Lanfranchi

  • So from the script, there are very few possibilities. Clearly when it's getting to the "Get-Datastore" it has not yet successfully established a connection.  The certificate error you mentioned is common when you don't replace the "built in" certificate with a trusted certificate, but can usually be ignored.  What I'd suggest doing is throwing -ErrorVariable $myError on the Connect-VIServer and just echoing the error out so you can see what is going on with the connection.  Or just removing the -ErrorAction SilentlyContinue to get it to show the real error.

    The other possibility is the difference between x64 and x86.  Though I believe if you have the wrong one selected for the application, you cannot even import the snap-in.  You can try changing the options in the application template to see if that makes a difference.

    An odd observation in your script, you are executing "Get-Datastore" and then just passing that response to a Message string.  Get-Datastore doesn't return a string, it usually returns an array of objects.  This will likely cause issues with the output.  If there is specific data you're looking for, you should output that.  Also from the screen shot, $stat is empty.  What are you trying to achieve?

    As a side note, there are better ways to pass credentials for PowerShell, actually any custom scripts, use the variable ${CREDENTIAL} as detailed here: http://www.solarwinds.com/documentation/en/flarehelp/sam/content/OrionAPMAGCreatingPowershellMonitor.htm  you can then use the user/pass in the template/component, rather than the actual code.

  • One thought that just crossed my mind, what version of PowerCLI are you using?  The version I still have running actually gives you a warning that future versions are going to handle invalid certificates.  Maybe your invalid certificate is causing issues with the actual connection.  You might need to look at Get-PowerCLIConfiguration, and see what it says for 'InvalidCertificateAction'.

  • Hi Jonathan

    Now, I set the "InvalidCertificateAction" = "Ignore", but now I become another Error:

    errorsw.PNG

    Wenn I try to execute the Powershell-Script on the Orion Server with Powershell ISE, it works without any issues.

    I really don't know, where the problem is.

    Thank you very much for the support!

    I'm running the PowerCLI 5.1 Release 2 Patch 1 build 1926866 Version in Powershell 2.0.

  • Ahh, that's right, forgot about the memory limitations.  This should answer your question.

    http://knowledgebase.solarwinds.com/kb/questions/4103/PowerShell+script+that+uses+VMware+PowerCLI+functions+in+SAM.

    I hit that one a year or so ago, you have to use a wrapper script to get around the problem.

  • Hi Jonathan

    Thank you very much for your Support.

    So I could execute my script! emoticons_happy.png

    Have a nice Day!

    Mirko Lanfranchi