Citrix MPS4 herstart script.



Voor de migratie van onze Citrix omgeving van MPS XP naar MPS4, moest ik mijn Reboot script aanpassen zodat deze compatible was met MPS4.

Hieronder zie je het script:
;============================================
; Rebootscript voor KVK/CITRIX FARM
;
; Created by Arne Fokkema
; Copyright KvK Noordwest-Holland 2004
;
; * Clean Print Spooler * Reboot the Server * Write Event Log
;
;============================================

SetConsole(“maximize”)

$Fileserver = “fileservernaam”
$Logfile = “\\$Fileserver\Log$\Herstart\@WKSTA_REBOOT.txt”
$MACADDRESS = @ADDRESS
$IPADDRESS = @IPADDRESS0
$Werkstation = @WKSTA

;//////////////////////////////////////////////// Logging \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\;
Function Log($Message,Optional $LogFile)
Dim $LogFile
$Log=’
$LogFile=’+$LogFile
If 0=VarType($Message) Exit(1) EndIf
If $LogFile
If NOT GetFileAttr(SubStr($LogFile,1,InStrRev($LogFile,’\’)-1)) & 16 Exit(2) EndIf
If RedirectOutput($LogFile,0)=0
? “@DATE, @TIME: $Message”
$=RedirectOutput(“”)
Else Exit(3) EndIf
EndIf
EndFunction

;//////////////////////////////////////////////// Reboot \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\;

$LogItem = Log(“******************************************************** “,$LogFile)
$LogItem = Log(“De “+$Werkstation+” wordt opnieuw gestart.”,$LogFile)
$LogItem = Log(“MAC: “+$MACADDRESS+ ” IP: “+$IPADDRESS,$LogFile)

$LogItem = Log(“Shutting down the IMA Service. “,$LogFile)
?”Stop de IMA service”
Shell ‘%comspec% /e:1024 /c net stop “Independent Management Architecture” /Y’
If @error $LogItem = Log(“de IMA Service is NIET uitgeschakeld. “,$LogFile)
Else
$LogItem = Log(“de IMA Service is uitgeschakeld. “,$LogFile)
Endif

? “Sending a message”
Shell ‘%comspec% /e:1024 /c “msg /TIME:600 * Deze server wordt over 15 minuten opnieuw gestart.”‘
$LogItem = Log(“Sending the 15 minutes warning. “,$LogFile)
sleep 600
$LogItem = Log(“Shutting down the print spooler. “,$LogFile)
?”Stop de spooler service”
Shell ‘%comspec% /e:1024 /c net stop “print spooler” /y’
If @error $LogItem = Log(“de Print spooler Service is NIET uitgeschakeld. “,$LogFile)
Else
$LogItem = Log(“de Print spooler Service is uitgeschakeld. “,$LogFile)
Endif

? “Sending a message”
Shell ‘%comspec% /e:1024 /c “msg /TIME:180 * Deze server wordt over 5 minuten opnieuw gestart.”‘
$LogItem = Log(“Sending the 5 minutes warning. “,$LogFile)
sleep 240

$LogItem = Log(“Deleting print queues. “,$LogFile)
?”Deleting the Print Queues”
del “%Windir%\System32\spool\PRINTERS\*.* /q”
$LogItem = Log(“Starting Shutdown. “,$LogFile)
?”Starting Shutdown”
? “Sending a message”
Shell ‘%comspec% /e:1024 /c “msg /TIME:30 * Deze server wordt over 1 minuut opnieuw gestart.”‘
$LogItem = Log(“Sending the 1 minute warning. “,$LogFile)
sleep 60

;* disable logon’s
Shell ‘%comspec% /e:1024 /c “change logon /enable”‘
$LogItem = Log(“Nieuw logins zijn ingeschakeld. “,$LogFile)

$LogItem = Log(“Starting shutdown. “,$LogFile)
Shell ‘%comspec% /e:1024 /c “C:\Progra~1\Reboot\shutgui.exe /C /R /T:30″‘
If @error = 0
$LogItem = Log(“Shutdown Accepted. “,$LogFile)
goto “exit”
Else
Goto “Timeout”
Endif
:timeout
$LogItem = Log(“Aborted – Shutdown script timed out. “,$LogFile)

:exit
?”Exit”
$LogItem = Log(“exited. “,$LogFile)
$LogItem = Log(“******************************************************** “,$LogFile)

Het script stopt een aantal services, maakt de spooler directory leeg en start vervolgens de server opnieuw op. Voordat de server opnieuw opgestart wordt krijgen de gebruikers drie keer een melding.

Het script schedule je via een scheduled task.

Bij het script zit ook een logbestand deze ziet er als volgt uit:

2006/08/08, 12:38:31: ********************************************************
2006/08/08, 12:23:31: De SE37BTS2 wordt opnieuw gestart.
2006/08/08, 12:23:31: MAC: 00096BA373F9 IP: 10.185. 41.222
2006/08/08, 12:23:31: Nieuwe logins zijn uitgeschakeld.
2006/08/08, 12:23:31: Shutting down the IMA Service.
2006/08/08, 12:23:36: de IMA Service is uitgeschakeld.
2006/08/08, 12:23:36: Sending the 15 minutes warning.
2006/08/08, 12:33:36: Shutting down the print spooler.
2006/08/08, 12:33:39: de Print spooler Service is uitgeschakeld.
2006/08/08, 12:33:39: Sending the 5 minutes warning.
2006/08/08, 12:37:39: Deleting print queues.
2006/08/08, 12:37:39: Starting Shutdown.
2006/08/08, 12:37:39: Sending the 1 minute warning.
2006/08/08, 12:38:39: Nieuw logins zijn ingeschakeld.
2006/08/08, 12:38:39: Starting shutdown.
2006/08/08, 12:38:39: Shutdown Accepted.
2006/08/08, 12:38:39: exited.
2006/08/08, 12:38:40: ********************************************************

Advertisements

2 thoughts on “Citrix MPS4 herstart script.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s