'*********************************************************************** ' ' ' svrOffline.vbs ' ' Description: Take a Citrix Presentation server "offline" by unpublishing all applications ' published from the server. The published app names are stored ' to a text file so that the server can be brought back 'online" ' using the svrOnline script. ' ' Usage: One optional command line parameters - 1) Citrix server name (case ' sensitive ' ' e.g. >cscript svrOffline.vbs MFXPTS05 ' '*********************************************************************** ' Get server name from command line or input box Set objArgs = WScript.Arguments If objArgs.Count > 1 Then srvName = objArgs(0) Else srvName = InputBox("Enter the servername: ") End If ' Initialize MetaframeFarm Set Farm=CreateObject("MetaframeCOM.MetaframeFarm") Farm.Initialize 1 ' Create text file to hold application names Set fso = CreateObject("Scripting.FileSystemObject") Set fp = fso.CreateTextFile(srvname & ".txt", True, False) ' Loop through servers in the farm, then each app on that server For Each mfserver in Farm.servers If mfserver.servername = ucase(srvname) Then Set aApps = mfserver.Applications ' Loop through the apps For Each app in aApps Set mfApp = CreateObject("MetaframeCOM.MetaframeApplication") mfApp.Initialize 3, app.DistinguishedName mfApp.LoadData True WScript.sleep 500 mfApp.RemoveServer UCase(trim(srvname)) mfApp.SaveData fp.WriteLine app.DistinguishedName set mfApp = Nothing Next End If Next fp.Close set fp = Nothing Set aApps = Nothing set Farm = Nothing MsgBox "Citrix Server "& srvname &" Offline and Ready for Maintenance"