My scripting plans were foiled twice this week on Windows 2008 R2.
I have implemented a VBScript XenApp reboot script for several years now on several XenApp farms. I decided to convert to a Powershell script for a client’s XenApp 6 farm but ran into problem one: a scheduled task which runs when the user is not logged in cannot send interactive messages. Put another way, my reboot script cannot send a message using the MSG command to users on the server informing them that the server will reboot, and rebooting a XenApp server without notifying the users is not a good thing! I went back to the drawing board and used the XenApp 6 policy reboot functionality based on worker groups and a startup script which adds XenApp servers to a “Reboot Odd” or “Reboot Even” worker group based on the last digit of the computer name (the script also moves the server into the correct XenApp Servers folder, assigns the correct load evaluator and moves the server to the correct XenApp zone).
Problem two: For reasons I now cannot remember I needed a script which was running in the local SYSTEM context to spawn a process running as a domain user. Easy, PSEXEC to the rescue….. hmmm, no, it seems PSEXEC uses a call which cannot be used running as SYSTEM. There are possibly other utilities I could have tried, but I worked around this issue by creating a scheduled task using SCHTASKS which runs under a domain account and is set to run once at 23:59. I start the task using SCHTASKS /Run /I /TN “TaskName”, wait for a few seconds and disable the task using SCHTASKS /change /TN “TaskName” /DISABLE. The benefit to this method is that the task can be enabled and run manually from the Task Schedular console.
Level 13 (Regus)
92 Albert St
We also have a virtual office in Wellington.
0800 000 141
PO Box 34797,
Birkenhead, Auckland 0746