Saturday, November 23, 2013

Script to get Citrix Xenapp offline server information over Email.

Script to get Citrix Xenapp offline server information over Email.

Create one Bat file and one VBScript.

Bat file to run qfarm /offline command and save the output in text file i.e. offline.txt and call mail.vbs file to send email

VBScript will send offline.txt data via Email.

Make sure you have information about SMTP server and port 25 needs to be open between Citrix server from which you

send email to SMTP server.

Valid email ID‘s

Service account should have rights on Citrix servers to run Qfarm /offline command.

Copy both file at same location like c:

Create Schedule task to get run bat file daily

Bat File Code:-

--------------------------------------------------------------------

cd c:

qfarm /offline >offline.txt

cscript mail.vbs

-----------------------------------------------------------------------

Save Bat file as offline.bat

Vbscript Code:-

-------------------------------------------------------------------------

Set objFSO = CreateObject("Scripting.FileSystemObject")

set objMailBody = objFSO.OpenTextFile(".\offline.txt", 1)

BodyText = objMailBody.ReadAll

Set objEmail = CreateObject("CDO.Message")

objEmail.From = "donotreply@abc.com"

objEmail.To = "nitin@abc.com"

objEmail.Subject = " Offline servers - Auto Generated Email"

objEmail.Textbody = BodyText

objEmail.Configuration.Fields.Item _

("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

objEmail.Configuration.Fields.Item _

("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _

"192.168.1.2"

objEmail.Configuration.Fields.Item _

("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

ObjEmail.AddAttachment "c:\offline.txt", "Picture", 1

objEmail.Configuration.Fields.Update

objEmail.Send

----------------------------------------------------------------------------

Save VBscript as mail.vbs

1 comment: