vmware / PowerCLI-Example-Scripts

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

Set-HVPool: Unable to update "AutomaticLogoffPolicy" and "AutomaticLogoffMinutes" #392

Closed rpaloni closed 3 years ago

rpaloni commented 3 years ago

Hi,

I have a Pool configured ad NEVER Logoff when disconnect I want to change it to AFTER 15 Minutes

If I try to use this command:

Set-HVPool -PoolName $PoolName -Key "desktopSettings.logoffSettings.automaticLogoffPolicy" -Value "AFTER"

I receive this error:

Exception calling "Desktop_Update" with "3" argument(s): "ExceptionType : VMware.Hv.InvalidArgument
ErrorMessage : A null value is invalid.
ParameterName : desktopSettings.logoffSettings.automaticLogoffMinutes"
At C:\Program Files\WindowsPowerShell\Modules\VMware.Hv.Helper\VMware.HV.Helper.psm1:6362 char:8
+        $desktop_helper.Desktop_Update($services,$item,$updates)
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : VimException_

Cause automaticLogoffMinutes is mandatory for automaticLogoffPolicy

So If I try to set automaticLogoffMinutes before automaticLogoffMinutes: Set-HVPool -PoolName $PoolName -Key "desktopSettings.logoffSettings.automaticLogoffMinutes" -Value 15

even if no error was given, the key was not updated in the pool probably cause automaticLogoffPolicy is set to NEVER.

How can I updates automaticLogoffMinutes and automaticLogoffPolicy simultanosly and correctly

rpaloni commented 3 years ago

Sorry for late... I solved by myself my issue.

It's not a bug. I'm only understand how the "Pool Object" is made. So...

$thisPool = Get-HVPool -PoolName $poolName

$logoffSettings = $thispool.DesktopSettings.LogoffSettings
$logoofSettings.AutomaticLogoffPolicy = AFTER
$logoofSettings.AutomaticLogoffMinutes= 15

Set-HVPool -Pool $thisPool -key "desktopSettings.logoffSettings" -value $logoffSettings
imtrinity94 commented 2 years ago

PS C:\Windows\system32> $patternSettings = $pool.AutomatedDesktopData.VmNamingSettings.PatternNamingSettings PS C:\Windows\system32> $patternSettings.MaxNumberOfMachines = 4 PS C:\Windows\system32> Set-HVPool -Poolname 'FulClnJSON' -Key 'automatedDesktopData.vmNamingSpec.patternNamingSettings' -Value $patternSettings Updating the Pool: FulClnJSON Exception calling "Desktop_Update" with "3" argument(s): "ExceptionType : VMware.Hv.InvalidArgument ErrorMessage : Invalid member name. ParameterName : automatedDesktopData.vmNamingSpec.patternNamingSettings" At C:\Program Files\WindowsPowerShell\Modules\VMware.Hv.Helper\VMware.HV.Helper.psm1:6442 char:8