vmware / PowerCLI-Example-Scripts

http://blogs.vmware.com/powercli
Other
754 stars 603 forks source link

Horizon update syslog servers: Could not load type 'VMware.Hv.String' #422

Closed mtelvers closed 3 years ago

mtelvers commented 3 years ago

Hi, I am trying to update my syslog servers for VMware Horizon but I can't get it to work. Can any shed any light on this?

$services = Get-ViewAPIService
$syslog_helper = New-Object VMware.Hv.SyslogService
$updates = @()
$updates += Get-MapEntry -key 'udpData.enabled' -value $true
$updates += Get-MapEntry -key 'udpData.networkAddresses' -value @('1.2.3.4:514', '5.6.7.8:514')
$syslog_helper.Syslog_Update($services, $updates)

This gives me this error:

Exception calling "Syslog_Update" with "2" argument(s): "Could not load type 'VMware.Hv.String' from
assembly 'VMware.Hvi, Version=8.1.0.158, Culture=neutral, PublicKeyToken=null'."
CajunBard commented 3 years ago

I wondering if it doesn't like your array, @('1.2.3.4:514', '5.6.7.8:514'). I'm checking into why that might me. You could try setting it another way, such as:

[string[]]$networkAddresses
$networkAddresses += '1.2.3.4:514'
$networkAddresses += '5.6.7.8:514'
...
$updates += Get-MapEntry -key 'udpData.networkAddresses' -value $networkAddresses
mtelvers commented 3 years ago

Hi, thanks for your comments. I did try a bunch of different ways of passing the array -- I even search through the whole module trying to find other parameters which were arrays to see how they were handled but I couldn't see any. Your code sample gives me

Exception calling "Syslog_Update" with "2" argument(s): "ExceptionType : VMware.Hv.InvalidType
ErrorMessage : Invalid argument type for this member.
ParameterName : udpData.networkAddresses
ExpectedType : ArrayOfString"
CajunBard commented 3 years ago

Ok I'm realizing that I actually made a typo in my recommendation, though I don't suspect it will materially impact the outcome. I'm trying to get a lab spun up where I can test this out.

[string[]]$networkAddresses = @()
$networkAddresses += '1.2.3.4:514'
$networkAddresses += '5.6.7.8:514'
...
$updates += Get-MapEntry -key 'udpData.networkAddresses' -value $networkAddresses
mtelvers commented 3 years ago

Great news - this works! Thanks very much for your help.