今天用户有个需求,需要在user disconnected 的时候 shutdown VM,查询了Citrix XenDesktop的管理文档,发现有相关介绍:

 在XD5的管理文档中的计算机电源管理有提高相关内容:

电源状态计时器
可以使用电源状态计时器在用户断开连接达到定义的时间之后,将桌面挂起。 例如,可以在非工作时间使桌面在用户断开连接至少 10 分钟后自动挂起。 除非使用 SDK 配置了桌面组的 ShutdownDesktopsAfterUse 属性,否则池计算机或流计算机始终会在用户注销时自动关闭。可以分别为平日(默认为星期一至星期五)和周末以及高峰期和非高峰期配置计时器。 高峰期包括大多数用户登录其桌面的时间,始于工作日的起始时间。 如果要在电源状态计时器计数完毕时关闭(而不是挂起)桌面,或者如果希望由注销(而不是断开连接)事件触发计时器,请使用 SDK。 还请注意,此过程中的平日和周末选项为默认选项,可以使用 SDK 进行配置。


有关于Power management 的相关PowerShell命令详解发现:

需要查看更详细的PowerShell命令请参考这里:http://support.citrix.com/static/kc/CTX127254/help/index.htm

ShutdownDesktopsAfterUse Whether desktops in this desktop group should be automatically shut down when each user session completes (only relevant to power-managed desktops). false false  

执行命令:set-brokerdesktopgroup -name [desktopgroup name] -shutdowndesktopsafteruse $true

依据上面的这些资料本来认为确实是可以实现的,但是执行了相关命令确实看不到应该有的效果,然后继续找文档,确实有以下收获:

需要查询更详细的请参考这里:http://support.citrix.com/proddocs/topic/xendesktop-rho/cds-control-power-management-rho.html

Power State Timers

You can suspend desktops after users have disconnected for a defined time using power state timers. For example, desktops can be made to suspend automatically outside office hours if users have been disconnected for at least 10 minutes. Unless you have configured the ShutdownDesktopsAfterUse property of a desktop group using the SDK, pooled or streamed machines are always automatically shut down when users log off.

You can configure the timers separately for weekdays (by default, Monday to Friday) and weekends, and for peak and off-peak periods. The peak period covers the time at which most users log on to their desktops, and starts at the beginning of your business day. Use the SDK if you want to shut down, rather than suspend, desktops in response to power state timers, or if you want the timers to be based on logoffs, rather than disconnections. Also, note that the Weekdays and Weekend selections in this procedure are defaults that can be configured using the SDK.

发现一定需要用户 log off 才能执行 Shutdown的命令。

OK,问题找到,现在问题的关键点是需要当用户disconnected之后logoff user。

解决办法:创建个 HDX Policy

具体路径:users-session limits-disconnected session timer                    enable

                    users-session limits-disconnected session timer    interval     你想要的时间

 

OK, 整个设定完成,Case解决。