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

GlobalSettings.GlobalSettings_Update can't update displayPreLoginMessage (and other boolen properties) via function #607

Open
Po-temkin opened this issue Mar 20, 2023 · 1 comment
Labels

Comments

@Po-temkin
Copy link

Po-temkin commented Mar 20, 2023

Describe the bug

I'm in the process of writing a function that will update all properties of $services.GlobalSettings.GlobalSettings_Get().GeneralData.
I know about that module VMware.Hv.Helper has Set-HVGlobalSettings cmdlet, but some new properties from Horizon 2212 aren't in it.
One of the properties is displayPreLoginMessage.
When I try to set this property via function, I see this:

Exception calling "GlobalSettings_Update" with "1" argument(s): "There is an error in the XML document."
At C:\Program Files\WindowsPowerShell\Modules\Potemkin.Hv.Helper\Potemkin.Hv.Helper.psm1:1271 char:5
+     $services.GlobalSettings.GlobalSettings_Update($updates)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : InvalidOperationException

I wrote a simple function to reproduce the error. You can find it below.
Interesting that everything is OK if I execute:

Set-HVGlobalGeneralSettings -DisplayPreLoginMessage $true

This also works (if i run it directly in shell):

$updates = Get-MapEntry -Key 'generalData.displayPreLoginMessage' -Value $false
$services.GlobalSettings.GlobalSettings_Update($updates)

UPD: The same situation with DisplayWarningBeforeForcedLogoff and EnableServerInSingleUserMode

Reproduction steps

  1. Take Get-MapEntry from VMware.Hv.Helper
  2. Execute Set-HVGlobalGeneralSettings
function Set-HVGlobalGeneralSettings {
  [CmdletBinding(
    SupportsShouldProcess = $false,
    ConfirmImpact = 'High'
  )]

  param(
    [Parameter(Mandatory = $false)]
    [boolean]
    $DisplayPreLoginMessage = $false
  )

  begin {
    $services = Get-ViewAPIService -hvServer $hvServer
    if ($null -eq $services) {
      Write-Error "Could not retrieve ViewApi services from connection object"
      break
    }
  }

  process {
    $updates = @()
    if ($DisplayPreLoginMessage) {
      $updates += Get-MapEntry -Key 'generalData.displayPreLoginMessage' -Value $DisplayPreLoginMessage
    }

    $services.GlobalSettings.GlobalSettings_Update($updates)
  }

  end {
    $services.GlobalSettings.GlobalSettings_Get().GeneralData
    [System.gc]::collect()
  }
}

Expected behavior

DisplayPreLoginMessage updating without errors.

Additional context

Horizon Connection Server 8.8.0 build - 21073894
Powershell 5.1
PowerCLI 12.7

@Po-temkin Po-temkin added the bug label Mar 20, 2023
@Po-temkin Po-temkin changed the title GlobalSettings.GlobalSettings_Update can't update displayPreLoginMessage via function GlobalSettings.GlobalSettings_Update can't update displayPreLoginMessage (ant other boolen propetries) via function Mar 20, 2023
@Po-temkin Po-temkin changed the title GlobalSettings.GlobalSettings_Update can't update displayPreLoginMessage (ant other boolen propetries) via function GlobalSettings.GlobalSettings_Update can't update displayPreLoginMessage (and other boolen propetries) via function Mar 20, 2023
@Po-temkin Po-temkin changed the title GlobalSettings.GlobalSettings_Update can't update displayPreLoginMessage (and other boolen propetries) via function GlobalSettings.GlobalSettings_Update can't update displayPreLoginMessage (and other boolen properties) via function Mar 20, 2023
@Mr-Kappelmann
Copy link

Mr-Kappelmann commented Feb 6, 2024

I know about that module VMware.Hv.Helper has Set-HVGlobalSettings cmdlet, but some new properties from Horizon 2303 aren't in it.
How to set new functions, that Set-HVGlobalSettings not provided?
With -Key and -Value they are not working.

$hvServer = Connect-HVServer *hvServer*
$ViewAPI = $hvServer.ExtensionData
Set-HVGlobalSettings -Key 'GeneralData.EnableAutomaticStatusUpdates' -Value $true

same as

$update = New-Object VMware.Hv.MapEntry
$update.Key = "GeneralData.EnableAutomaticStatusUpdates"
$update.Value = $true
$ViewAPI.GlobalSettings.GlobalSettings_update($update)

same as

$service = New-Object VMware.Hv.GlobalSettingsService
$service.GlobalSettings_Update($ViewAPI, $update)


Error:
MethodInvocationException: Exception calling "GlobalSettings_Update" with "1" argument(s): "ExceptionType : VMware.Hv.InvalidArgument
ErrorMessage : Invalid member name.
ParameterName : GeneralData.EnableAutomaticStatusUpdates"

Request of value works:
(Get-HVGlobalSettings).GeneralData.EnableAutomaticStatusUpdates
False

$ViewAPI.GlobalSettings.GlobalSettings_Get().GeneralData.EnableAutomaticStatusUpdates
False

$service.GlobalSettings_Get($ViewAPI).GeneralData.EnableAutomaticStatusUpdates
False

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

No branches or pull requests

2 participants