4 Replies Latest reply on Aug 14, 2018 5:58 AM by Starko423

    PowerCLI on Debian Stretch: The type initializer for 'VMware.VimAutomation.ViCore.Util10.SettingsManager' threw an exception.

    Starko423 Lurker

      Environment

      OS: Debian 9 Stretch amd64

      PS /root> get-host
      Name             : ConsoleHost
      Version          : 6.1.0-preview.2
      InstanceId       : 87acc50e-d2c7-4bf8-a667-5ddb22848a61
      UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
      CurrentCulture   : de-DE
      CurrentUICulture : de-DE
      PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
      DebuggerEnabled  : True
      IsRunspacePushed : False
      Runspace         : System.Management.Automation.Runspaces.LocalRunspace

      Import-Module VMware.VimAutomation.Core
      Get-Module VMware* | Select Name,Version

      PS /root> Get-Module VMware* | Select Name,Version

      Name                          Version
      ----                          -------
      VMware.Vim                    6.7.0.8343295
      VMware.VimAutomation.Cis.Core 10.1.0.8377811
      VMware.VimAutomation.Common   10.1.0.8342134
      VMware.VimAutomation.Core     10.1.0.8344055
      VMware.VimAutomation.Sdk      10.1.0.8342078

      Description

      Due to the new possibilites Microsoft offers the Linux community, I installed Microsoft PowerShell and Vmware PowerCLI on Debian.
      I want Zabbix Proxy to query VMware vCenter via External check.

      I wrote the following script:

      #!/usr/bin/pwsh
       
      param(
      [string]$Server,
      [string]$User,
      [string]$Password,
      [string]$VM
      )
      Import-Module VMware.VimAutomation.Core
      Connect-VIServer -Server $Server -User $User -Password $Password -Force | Out-Null
       
      $snapshot = Get-Snapshot -VM $VM
      $snapshot.Count
       
      Disconnect-VIServer -Server * -Force -Confirm:$false

       

      The script works very vell, when I start it in my SSH session. But as soon as Zabbix executes the script, the Module fails:

      VERBOSE: Import-Module:
      Import-Module : The type initializer for 'VMware.VimAutomation.ViCore.Util10.SettingsManager' threw an exception.
      At /usr/lib/zabbix/externalscripts/vmware.vm.snapshot.count.ps1:22 char:1
      + Import-Module VMware.VimAutomation.Core
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : OperationStopped: (:) [Import-Module], TypeInitializationException
      + FullyQualifiedErrorId : System.TypeInitializationException,Microsoft.PowerShell.Commands.ImportModuleCommand

      Is this a bug I can report anywhere? Is this egiable for Vmware support? Or can someone help me here?

        • 1. Re: PowerCLI on Debian Stretch: The type initializer for 'VMware.VimAutomation.ViCore.Util10.SettingsManager' threw an exception.
          LucD Guru
          User ModeratorsvExpertCommunity Warriors

          There are a couple of things to note (see Release Notes):

          • Debian is currently not in the list of officially supported OS
          • PowerCLI is officially only supported with PowerShell 6.0.2, afaik due to a breaking change in the NetCore libraries

           

          Would you eventually have the option to go back to PowerShell Core 6.0.2?

           

          Since the script seems to work when you run it under your credentials, is Zabbix running under the same account?
          Do you have the same Path definitions for both accounts?

           

          On your support question, see PowerCLI Support Breakdown

          But since you are using an OS and a PS version that is not officially supported, I'm doubtful that you would be able to open a SR.

          But the community (where you asked) might help.

          • 2. Re: PowerCLI on Debian Stretch: The type initializer for 'VMware.VimAutomation.ViCore.Util10.SettingsManager' threw an exception.
            Starko423 Lurker

            In the last hour I installed a completely new additional Zabbix Proxy. It's Ubuntu 16.04. I Installed PowerShell Core 6.0.2.

            root@zabbix-ubuntu:/usr/lib/zabbix/externalscripts# lsb_release -a
            No LSB modules are available.
            Distributor ID: Ubuntu
            Description:    Ubuntu 16.04.5 LTS
            Release:        16.04
            Codename:       xenial

            get-host

            Name             : ConsoleHost
            Version          : 6.0.2
            InstanceId       : db63dd07-ea01-4e6e-9a6d-213bfdc66dd5
            UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
            CurrentCulture   : de-DE
            CurrentUICulture : de-DE
            PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
            DebuggerEnabled  : True
            IsRunspacePushed : False
            Runspace         : System.Management.Automation.Runspaces.LocalRunspace

            PS /usr/lib/zabbix/externalscripts> Import-Module VMware.VimAutomation.Core
            PS /usr/lib/zabbix/externalscripts> Get-Module VMware* | Select Name,Version                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Name                          Version
            ----                          -------
            VMware.Vim                    6.7.0.8343295
            VMware.VimAutomation.Cis.Core 10.1.0.8377811
            VMware.VimAutomation.Common   10.1.0.8342134
            VMware.VimAutomation.Core     10.1.0.8344055
            VMware.VimAutomation.Sdk      10.1.0.8342078

            Debian is currently not in the list of officially supported OS
            > I switched to Ubuntu, the error persists.

            > Would you eventually have the option to go back to PowerShell Core 6.0.2?
            I switched to PowerShell 6.0.2, the error persists.

            > Since the script seems to work when you run it under your credentials, is Zabbix running under the same account?
            Yes, I checked running the script as the deamon user. No difference.

            > Do you have the same Path definitions for both accounts?
            Yes.

            How can we furher test? I attach the log:

            Value "Script Name
            vmware.vm.snapshot.count.ps1
            VCSA Host IP
            10.23.0.200
            Username
            monitoring@vsphere.local
            Password
            xxx
            Virtual machine
            server-domain.local
            VERBOSE: Server:
            10.23.0.200
            VERBOSE: User:
            monitoring@vsphere.local
            VERBOSE: Password:
            xxx
            VERBOSE: VM:
            server-domain.local
            VERBOSE: Connection string:
            Connect-VIServer -Server 10.23.0.200 -User monitoring@vsphere.local -Password xxx -Force


            Name : ConsoleHost
            Version : 6.0.2
            InstanceId : 5d257a8c-98d3-4787-b4a3-a02cd71c7141
            UI : System.Management.Automation.Internal.Host.InternalHostUserI
            nterface
            CurrentCulture : de-DE
            CurrentUICulture : de-DE
            PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
            DebuggerEnabled : True
            IsRunspacePushed : False
            Runspace : System.Management.Automation.Runspaces.LocalRunspace

            VERBOSE: Import-Module:
            Import-Module : The type initializer for 'VMware.VimAutomation.ViCore.Util10.SettingsManager' threw an exception.
            At /usr/lib/zabbix/externalscripts/vmware.vm.snapshot.count.ps1:25 char:1
            + Import-Module VMware.VimAutomation.Core
            + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            + CategoryInfo : OperationStopped: (:) [Import-Module], TypeInitializationException
            + FullyQualifiedErrorId : System.TypeInitializationException,Microsoft.PowerShell.Commands.ImportModuleCommand

            VERBOSE: Get-Module:
            Name : VMware.VimAutomation.Sdk
            Version : 10.1.0.8342078

            Connect-VIServer : The type initializer for 'VMware.VimAutomation.ViCore.Util10.SettingsManager' threw an exception.
            At /usr/lib/zabbix/externalscripts/vmware.vm.snapshot.count.ps1:30 char:1
            + Connect-VIServer -Server $Server -User $User -Password $Password -For ...
            + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            + CategoryInfo : NotSpecified: (:) [Connect-VIServer], TypeInitializationException
            + FullyQualifiedErrorId : System.TypeInitializationException,VMware.VimAutomation.ViCore.Cmdlets.Commands.Co

            • 4. Re: PowerCLI on Debian Stretch: The type initializer for 'VMware.VimAutomation.ViCore.Util10.SettingsManager' threw an exception.
              Starko423 Lurker

              I don't think I have an answer. If I do "apt search netcore" I do find several releases, but none of them are installed.

              What I did to install PowerShell is:

               

              curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

              curl -o /etc/apt/sources.list.d/microsoft.list https://packages.microsoft.com/config/ubuntu/16.04/prod.list

              apt update

              apt install powershell=6.0.2-1.ubuntu.16.04

              pwsh

              Install-Module -Name VMware.PowerCLI -Force