I recently had the opportunity to work with 2 consultants from Citrix Consulting Services for a client who has been experiencing performance issues in their remote office and one of the recommendations was to schedule weekly reboots for their dedicated desktops on a weekly basis to eliminate any issues caused by memory leaks in the Windows 7 operating system. This, as some administrators know, can be done by using the Set-BrokerDesktopGroup cmdlet with the -ShutdownDesktopsAfterUse while playing around with the Power on/off machines option to force VDIs to get powered up after it has been shutdown. The challenge with this is that you may have a window where the VDIs are shutdown and if you need to simply do a quick restart every day or every week, this may not work. Furthermore, the client that I’m working with would like a restart prompt presented to users who are logged on at a set time with the option of allowing them to either allow a reboot or cancel it.
After doing a bit of research, I came to realize that one of ways to do this was to use a batch file and the best one I found was here:
@ECHO OFF
:myLabel
SHUTDOWN /S /F /T 600
SET /P continue="Your computer is about to shutdown in 10 min do you want to abort (y/n): "
IF %continue% EQU y (
SHUTDOWN /A
)
The batch file command above shuts down the desktop so a small change needs to be made to the switches so it looks as such instead:
@ECHO OFF
:myLabel
SHUTDOWN /R /F /T 600
SET /P continue="Your computer is about to restart in 10 min do you want to abort (y/n): "
IF %continue% EQU y (
SHUTDOWN /A
)
If you launch these commands in a batch file, you will get a cmd prompt window open allowing the user to hit Y to abort the restart and N to allow. In addition to the cmd prompt window, a regular Windows window would pop up indicating that the computer will be restarted in 10 minutes and if shutdown is aborted, the user will see a small notification bubble at the task bar reading:
Logoff is cancelled
The scheduled shutdown has been cancelled.
With this batch file in hand, you can then create a new GPO to assign to the Active Directory OU containing the computer objects as such:
Note that it is obviously not best practice to user a regular user account for this so create a proper service account to run this scheduled task:
Configure the frequency of the restart:
Place the batch file to a network location:
Once this GPO is created and the desktop has refreshed Group Policy, you should see the scheduled task as such:
The small batch file may not be the most visual appealing but I can see this being useful to have whether it’s used for a virtual or physical desktop.
2 comments:
Your client should get his money back. What Windows 7 memory leaks? What a joke.
Is this a comedy show ? this guy is a joke man
Post a Comment