Users Cannot Connect To Desktops Flagged with Hidden 'WillshutdownAfterUse' Parameter

Users Cannot Connect To Desktops Flagged with Hidden 'WillshutdownAfterUse' Parameter

book

Article ID: CTX134190

calendar_today

Updated On:

Description

When attempting to start a desktop, users receive the following error, even though there are desktops listed as ‘Ready’ in the target desktop group:

User-added image

The XML broker logs the following events:

Event ID: 30112, Citrix Web Interface

No available resource found for user domain\user when accessing desktop group Desktop Group. This message was reported from the Citrix XML Service at address http://localhost/scripts/wpnbr.dll [com.citrix.xml.NFuseProtocol.RequestAddress].

User-added image

Event ID: 1101, Citrix Broker Service

The Citrix Broker Service failed to broker a connection for user Domain\User to resource Desktop Group. The Citrix Broker Service cannot find any available virtual machines.

User-added image

Environment

The above mentioned sample code is provided to you as is with no representations, warranties or conditions of any kind. You may use, modify and distribute it at your own risk. CITRIX DISCLAIMS ALL WARRANTIES WHATSOEVER, EXPRESS, IMPLIED, WRITTEN, ORAL OR STATUTORY, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NONINFRINGEMENT. Without limiting the generality of the foregoing, you acknowledge and agree that (a) the sample code may exhibit errors, design flaws or other problems, possibly resulting in loss of data or damage to property; (b) it may not be possible to make the sample code fully functional; and (c) Citrix may, without notice or liability to you, cease to make available the current version and/or any future versions of the sample code. In no event should the code be used to support ultra-hazardous activities, including but not limited to life support or blasting activities. NEITHER CITRIX NOR ITS AFFILIATES OR AGENTS WILL BE LIABLE, UNDER BREACH OF CONTRACT OR ANY OTHER THEORY OF LIABILITY, FOR ANY DAMAGES WHATSOEVER ARISING FROM USE OF THE SAMPLE CODE, INCLUDING WITHOUT LIMITATION DIRECT, SPECIAL, INCIDENTAL, PUNITIVE, CONSEQUENTIAL OR OTHER DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Although the copyright in the code belongs to Citrix, any distribution of the sample code should include only your own standard copyright attribution, and not that of Citrix. You agree to indemnify and defend Citrix against any and all claims arising from your use, modification or distribution of the sample code.

Resolution

To prevent this issue from occurring, ensure that the Desktop Delivery Controller (Controller) is able to power manage virtual machines on the target hosting infrastructure by right-clicking on any desktop and clicking Shut Down or Restart. Check your hypervisor console to ensure the power action takes place. If this does not take place, additional troubleshooting will be required to address this.

Citrix recommends creating a schedule to restart Virtual Machines during an off-peak time of possible, which will clear the WillShutdownAfterUse flag.

The following PowerShell script can also be used to clean up any desktops in a ‘tainted’ state, and can be run weekly to ensure that no desktops remain in this state: 

$dirtyvms = Get-BrokerDesktop -PowerActionPending $false -PowerState On -SummaryState Available -WillShutdownAfterUse $true
foreach ($vm in $dirtyvms)
{
New-BrokerHostingPowerAction -Action 'Restart' -MachineName $vm.HostedMachineName
}

Note: If you are using XenDesktop 5.6, use the following command:

New-BrokerHostingPowerAction -Action 'Restart' -MachineName $vm.MachineName

Problem Cause

This problem occurs when a Desktop Group is configured with the ‘ShutdownAfterUse’ parameter, but is not properly shutdown by the XenDesktop DDC after use. When a session is started to a desktop group with the ‘ShutdownAfterUse’ setting enabled, the desktop is flagged with a parameter called ‘WillShutdownAfterUse’. This flag is cleared when the desktop is shut down by the Controller, so if/when a ‘ShutdownAfterUse’ power action fails, the worker remains in this state until the desktop is successfully power managed by the Controller. Desktops will also reach this state when placed into maintenance mode while a session is active, and logged off while still in maintenance mode.

Idle pool buffers facilitate cleaning of ‘tainted’ desktops when transitioning from peak to off-peak schedules. However, if both peak and off-peak idle pool buffers are set to 100%, desktops will remain in this state until restarted by XenDesktop.

The following PowerShell command list all desktops in this state:

Get-BrokerDesktop -PowerActionPending $false -PowerState On -SummaryState Available -WillShutdownAfterUse $true | fl MachineName

Issue/Introduction

This article provides resolution when users are unable to connect to specific desktop groups when desktops are not restarted to clear a hidden parameter.