Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fullenw1 opened this issue Sep 7, 2023 · 1 comment
Open

Comments

@fullenw1
Copy link

fullenw1 commented Sep 7, 2023

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.

@martincrothers
Copy link

martincrothers commented Jan 27, 2025

For me, I noticed that this issue only occurs within Visual Studio Code. I can run scripts directly from a separate PS7 window, but not the integrated terminal in VSCode.

Running:

  • Visual Studio Code: 1.96.4 (and a few previous versions)
  • PowerShell 7.5.0 (and a few previous versions)
  • Both Windows 10 and Windows 11

#Update
I was able to solve the problem for myself by fully removing all of the WMware related modules/packages from PS7. There are a lot that VMware.PowerCLI installs as dependencies, and they're interdependent, so they have to be uninstalled in order. Sorry, I didn't make note of the order.

I started with:

Get-Module -ListAvailable -Refresh | Where-Object {$_.Name -like 'VMware*'} | Uninstall-Module

Some of those won't uninstall because of the dependencies. I ran it a couple times instead of trying to figure out the dependency tree :)

I then had to close all PowerShell sessions to unlock one of the packages (I think it was the VMware.VimAutomation.Cis.Core package) and then use:

Uninstall-Package -Name VMware.VimAutomation.Cis.Core

And do the same for all remaining modules/packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants