I'm very new to powershell and am writing a script to reboot our Citrix XenApp servers. I think I'm doing everything well, but am getting stuck in one part and can't really understand.
So the script will go and query a workergroup to get all the servers on the workergroup, it will then change the logon to Prohibit logons until a restart.
I want to put a time-freeze so that it will run again in about 5 hours.
I'm attaching my little script below.
#reboot servers with 0 load
#second reboot – five hours later
When I check this variable, it is empty and when I check the server that had a load during the initial reboot, whkch should be logon -prohibited, it is acutally enabled. When I run line by line, when the Reboot Servers with 0 load runs, it actually doesn't reboot the server but changes the logon state to "Allow logon"
Why is this happening?
Hi Jay Q,
I'm not a citrix chap, but these lines stand out to me :
$InitialReboot | Get-XAServerLoad -ComputerName name | where load -eq 0 Restart-Computer $InitialReboot.servername -ErrorAction SilentlyContinue
The first line won't do anything other than list to the screen servers which have a load of 0 because you're not doing anything involving variable assignment or passing the information along the pipeline.
The second line looks like it will restart all the servers in $initialreboot?
I suspect that pipe after the $InitialReboot on the first line was supposed to the an equal sign (assignment operator) or some other variable was supposed to be assigned to be used in the second statement.
You must be logged in to reply to this topic.