Error when ruuning PowerCLI from .Net application

This post was originally published on this site

Hi,

 

I have a .Net app which runs some PowerCLI scripts. I’ve recently had to rebuild my PC an LAB environment and now certain comands are throwing an error.

 

The error is : “Could not retrieve handler field info from the HttpClient .net type.”

 

It only seems to happen with cetain cmdlets such as:

 

Start-VM

Stop-VM

Set-VM

New-VM

 

Which are the cmdlets which conflict with the Hyper-V module. I haven’t installed the Hyper-V module and doing a (get-module -ListAvailable).path doesn’t tell me its installed.

 

I’m using the latest version of PowerCLI , but have also tried installing older versions

 

My $psversiontable is:

 

Name                           Value

—-                           —–

PSVersion                      5.1.18362.1110

PSEdition                      Desktop

PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}

BuildVersion                   10.0.18362.1110

CLRVersion                     4.0.30319.42000

WSManStackVersion              3.0

PSRemotingProtocolVersion      2.3

SerializationVersion           1.1.0.1

 

Versions of .Net installed

>=4.x        : 4.8 or later

v4Client    : Installed

v4Full      : Installed

v3.5         : Installed

v3.0         : Installed

v2.0.50727   : Installed

v1.1.4322    : Not installed (no key)

 

I’m using vSphere 6.7

 

This only happens when running the scripts from my .Net app and was all working fine before I had to recreate my environment.

 

If i run the scripts from within PowerShell they run with no issue, which I know points to somekind of conflict with my app and not a PowerCli issus but im a bit lost as to know where to go next , so hoping someone can shed some light. Searching for the error online doesn’t throw up anything.

 

thanks in advance

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.