solarwinds / OrionSDK

SDK for the SolarWinds Orion platform, including tools, documentation, and samples in PowerShell, C#, Go, Perl, and Java.
https://thwack.com/OrionSDK
Apache License 2.0
394 stars 139 forks source link

SwisPowerShell 3.2.0.50049 is incompatible with VMWare.PowerCli in PS7 #348

Open fullenw1 opened 11 months ago

fullenw1 commented 11 months ago

Both were working just fine until I upgraded SwisPowerShell to version 3.2.0.50049.

Now, if I load SwisPowerShell first I cannot load VMWare.PowerCli anymore. And if I load VMWare.PowerCli first, then the Connect-Swis cmdlet returns an error.

This behavior only appears in a PowerShell 7 host (7.3.6 precisely in my case).

Loading SwisPowerShell first

PS> Connect-Swis -Hostname $OrionDatabaseServer -Credential $OrionCred

OperationTimeout Channel ClientChannel ChannelFactory
---------------- ------- ------------- --------------
01:00:00                               System.ServiceModel.ChannelFactory`1[SolarWinds.InformationService.Contract2.IStreamInformationServiceChannel]

PS>  Import-Module -Name VMware.PowerCLI
Import-Module: Unable to find type [VMware.VimAutomation.Sdk.Interop.V1.CoreServiceFactory].

Loading VMware.PowerCLI first

PS>  Import-Module -Name VMware.PowerCLI
          Welcome to VMware PowerCLI!

Log in to a vCenter Server or ESX host:              Connect-VIServer
To find out what commands are available, type:       Get-VICommand
To show searchable help for all PowerCLI commands:   Get-PowerCLIHelp
Once you've connected, display all virtual machines: Get-VM
If you need more help, visit the PowerCLI community: Get-PowerCLICommunity

       Copyright (C) VMware, Inc. All rights reserved.

PS> Connect-Swis -Hostname $OrionDatabaseServer -Credential $OrionCred
Connect-Swis: The type initializer for 'SolarWinds.InformationService.Contract2.InfoServiceProxy' threw an exception.

Troubleshooting

What is strange is that even after unloading the other module, the issue still remains in both cases.

As a workaround, downgrading SwisPowerShell to version 3.1.0.343 fixes the issue.

I noticed this behavior only in a PS7 host. So using a PowerShell 5.1 host can be another workaround.