VMware Cloud Community
BoomBoomB
Contributor
Contributor

Horizon 7 Pool changes via Powercli

I have Horizon 7 environment that requires some automation. I am using powercli and vmware.hv.helper

$p = Get-HVPool -poolname '<poolname>'

this is the setting needing to change:

$p.DesktopSettings.LogoffSettings.PowerPolicy

to either of these values:

ALWAYS_POWERED_ON

POWER_OFF

TAKE_NO_POWER_ACTION

but when I try to use the set-HVPool, I am getting error:

with this command:

Set-HVPool -PoolName $p.base.name -Key 'DesktopSettings.LogoffSettings.PowerPolicy' -Value 'TAKE_NO_POWER_ACTION'

the error is:

Exception calling "Desktop_Update" with "3" argument(s): "ExceptionType : VMware.Hv.InvalidArgument

ErrorMessage : Invalid member name.

ParameterName : DesktopSettings.LogoffSettings.PowerPolicy"

At C:\Users\xxxxx\Documents\WindowsPowerShell\Modules\VMware.Hv.Helper\Modules\VMware.Hv.Helper\VMware.HV.Helpe

r.psm1:6171 char:8

+        $desktop_helper.Desktop_Update($services,$item,$updates)

+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : VimException

and with this command

Set-HVPool -PoolName $p.base.name -Key $p.DesktopSettings.LogoffSettings.PowerPolicy -Value 'TAKE_NO_POWER_ACTION'

the error is:

Exception calling "Desktop_Update" with "3" argument(s): "ExceptionType : VMware.Hv.InvalidArgument

ErrorMessage : Invalid member name.

ParameterName : ALWAYS_POWERED_ON"

At C:\Users\xxxxxx\Documents\WindowsPowerShell\Modules\VMware.Hv.Helper\Modules\VMware.Hv.Helper\VMware.HV.Helper.psm1:6171 char:8

+        $desktop_helper.Desktop_Update($services,$item,$updates)

+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : VimException

Any Idea?

Thanks

0 Kudos
3 Replies
pzike
Contributor
Contributor

Keys are case-sensitive, try using 'desktopSettings.logoffSettings.powerPolicy' which is from View API - VMware API Explorer - VMware {code} (Name column)

I'm working on my own automation script and I was able to set the Power Policy fine using the above (and many other pool settings besides), however I'm getting the same error that you are while trying to enable 3D renderer with 'DesktopSettings.displayProtocolSettings.pcoipDisplaySettings.renderer3D'. I wish there was more documentation for this stuff.

0 Kudos
MisterSpo
Contributor
Contributor

I just spent two hours trying to run a simple command and I think I figured out the syntax.  Try changing the first letter in the first word in a concatenated string to lower case, but every remaining word in the string to start with a capital letter.  I hate that it's so persnickety, it's not helpful.

Here is the code I was trying to run:

$pools = Get-HVPool

foreach($pool in $pools | where {!$_.ManualDesktopData})

    {

        if($pool.DesktopSettings.LogoffSettings.DeleteOrRefreshMachineAfterLogoff -eq "REFRESH")

            {

                #Write-Host "Setting" $pool.Base.Name "to NEVER refresh at logoff."

                Set-HVPool -Pool $pool -Key "desktopSettings.logoffSettings.deleteOrRefreshMachineAfterLogoff" -Value "NEVER" #-WhatIf

            }

    }

Notice that the first letter of each word in it's portion of the string are lower case:

desktopSettings

logoffSettings

deleteOrRefreshMachineAfterLogoff

Hope this helps.

0 Kudos
Deepak_Sharma08
Contributor
Contributor

am getting same error while updating network setting of pool. By default, it accepts the same network as that of golden image however when am changing it, it gives same error.

Set-HVPool -PoolName $PoolName -Key "AutomatedDesktopData.VirtualCenterNamesData.NetworkLabelNames" -Value $NetworkPort

I have also tried with lowercase but no help.

Set-HVPool -PoolName $PoolName -Key "automatedDesktopData.virtualCenterNamesData.networkLabelNames" -Value $NetworkPort

Can anyone suggest what I can do to update the network setting of pool?

0 Kudos