PowerCLI-Example-Scripts
PowerCLI-Example-Scripts copied to clipboard
Can't create DEDICATED pool - deleteOrRefreshMachineAfterLogoff exception
Error when calling new-hvpool:
Exception calling "Desktop_Create" with "2" argument(s): "ExceptionType : VMware.Hv.InvalidArgument ErrorMessage : deleteOrRefreshMachineAfterLogoff can only be set for floating user assignment ParameterName : desktopSettings.logoffSettings.deleteOrRefreshMachineAfterLogoff" At C:\Scripts\modules\VMware.Hv.Helper\VMware.HV.Helper.psm1:4905 char:7
-
$id = $desktop_helper.Desktop_create($services,$desktopSpecObj) -
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~- CategoryInfo : NotSpecified: (:) [], MethodInvocationException
- FullyQualifiedErrorId : VimException
This happens whether or not I specify this value "deleteOrRefreshMachineAfterLogoff". If I switch the a FLOATING pool type, it works, but I need it working on dedicated.
I had in these days the same issue. I temporarly solved by editing VMware.Hv.Helper.psm1
Replace from Line 4826 with (to check i InstantPool is DEDICATED):
$desktopLogoffSettings = $desktopSettingsService.getDesktopLogoffSettingsHelper()
if ($InstantClone) {
$powerPolicy = "ALWAYS_POWERED_ON"
}
if ($InstantClone -and ($desktopUserAssignment.UserAssignment -ne "DEDICATED")) {
$deleteOrRefreshMachineAfterLogoff = "DELETE"
}
$desktopUserAssignment
$desktopLogoffSettings.setPowerPolicy($powerPolicy)
$desktopLogoffSettings.setAutomaticLogoffPolicy($automaticLogoffPolicy)
$desktopLogoffSettings.setAutomaticLogoffMinutes($automaticLogoffMinutes)
$desktopLogoffSettings.setAllowUsersToResetMachines($allowUsersToResetMachines)
$desktopLogoffSettings.setAllowMultipleSessionsPerUser($allowMultipleSessionsPerUser)
if (($desktopUserAssignment.UserAssignment -ne "DEDICATED")) { $desktopLogoffSettings.setDeleteOrRefreshMachineAfterLogoff($deleteOrRefreshMachineAfterLogoff) }
This appears to still be an issue. I get the same error as @mattivoxy I haven't looked at the workaround provided by @rpaloni as this was 2 1/2 years ago and line 4826 might not be where it was!
New-HVPool -InstantClone -PoolName $Pool_Name -PoolDisplayName $Pool_Display_Name -UserAssignment $User_Assignment -AutomaticLogoffPolicy $Automatic_Logoff_Policy -AutomaticLogoffMinutes $Automatic_Logoff_Minutes -allowUsersToResetMachines $Allow_Users_To_ResetMachines -allowMultipleSessionsPerUser $Allow_Multiple_Sessions_Per_User -defaultDisplayProtocol $Default_Display_Protocol -enableHTMLAccess $Enable_HTML_Access -Vcenter $vCenter -ParentVM $ParentVM -SnapshotVM $SnapshotVM -VmFolder $VmFolder -HostOrCluster $HostOrCluster -ResourcePool $ResourcePool -datacenter $Datacenter -Datastores $Datastores -UseVSAN $UseVSAN -NamingMethod $Naming_Method -NamingPattern $Naming_Pattern -MaximumCount $Maximum_Count -MinimumCount $Minimum_Count -SpareCount $Spare_Count -ProvisioningTime $Provisioning_Time -AdContainer $Ad_Container -NetBiosName $Net_Bios_Name -DomainAdmin $Domain_Admin -ReusePreExistingAccounts $ReusePreExistingAccounts -PostSynchronizationScriptName $Post_Synchronization_Script_Name
`Exception calling "Desktop_Create" with "2" argument(s): "ExceptionType : VMware.Hv.InvalidArgument ErrorMessage : deleteOrRefreshMachineAfterLogoff can only be set for floating user assignment ParameterName : desktopSettings.logoffSettings.deleteOrRefreshMachineAfterLogoff" At D:\Config\DeployPools\PowerCLI-Example-Scripts-master\Modules\VMware.Hv.Helper\VMware.HV.Helper.psm1:5002 char:7
-
$id = $desktop_helper.Desktop_create($services,$desktopSpecObj) -
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~- CategoryInfo : NotSpecified: (:) [], MethodInvocationException
- FullyQualifiedErrorId : VimException`
Cheers, Greg
Hi @gerguk. The last version of Vmware.HV.Helper Module seems was changed from the last time I download it. A changed was introduced to fix the problem but introduce a possible new bug.
$deleteOrRefreshMachineAfterLogoff is set as default to "NEVER" at line 3877 this parameter can be set only for Instant Clone Pool with Dedicated User Assignment
so...
In the actual version of the code you must search the lines 4953 - 4956
if ($InstantClone) {
$deleteOrRefreshMachineAfterLogoff = "DELETE"
$powerPolicy = "ALWAYS_POWERED_ON"
}
Replace them with
if ($InstantClone) {
$powerPolicy = "ALWAYS_POWERED_ON"
}
Replace Line 4962:
$desktopLogoffSettings.setDeleteOrRefreshMachineAfterLogoff($deleteOrRefreshMachineAfterLogoff)
with
if ($desktopUserAssignment.UserAssignment -eq "FLOATING ") {
$deleteOrRefreshMachineAfterLogoff = "NEVER"
}
$desktopLogoffSettings.setDeleteOrRefreshMachineAfterLogoff($deleteOrRefreshMachineAfterLogoff)
So... when Assignment is FLOATING the only value acceptable "NEVER" will set otherwise the value passed is used.
Hi @rpaloni,
I just wanted to thank you for taking the time to provide such accurate info.
I finally got around to modifying the VMware.HV.Helper.psm1 according to your instructions and am now able to create my Dedicated pools without any issues :-) The change hasn't had any impact on the creation of my Floating pools either
Many thanks, Greg
Hi @gerguk, You're welcome!