Monday, 9 April 2012

VB Script to start send ports/enable receive locations in Biztalk.



strComputer = "."
Set oMessage = CreateObject("CDO.Message")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\MicrosoftBizTalkServer")
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM MSBTS_SendPort where   Status=2",,48)
For Each objItem in colItems
      objItem.Start
     oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
      oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.urmailserver.com"
      oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
      oMessage.Configuration.Fields.Update
      oMessage.Subject = "Alerting text " &  objItem.Name
      oMessage.From = "myemailid@mymail.com"
      oMessage.To =  " myemailid@mymail.com ; myemailid1@mymail.com ; myemailid2@mymail.com "
      oMessage.TextBody = " Alerting text  " &  objItem.Name
      oMessage.Send
Next

VB Script to enable receive locatios in Biztalk.


strComputer = "."
Set oMessage = CreateObject("CDO.Message")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\MicrosoftBizTalkServer")
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM MSBTS_ReceiveLocation WHERE IsDisabled = True",,48)
For Each objItem in colItems
      objItem.Enable

  oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
      oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.urmailserver.com"
      oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
      oMessage.Configuration.Fields.Update
      oMessage.Subject = "Alerting text " &  objItem.Name
      oMessage.From = "myemailid@mymail.com"
      oMessage.To =  " myemailid@mymail.com ; myemailid1@mymail.com ; myemailid2@mymail.com "
      oMessage.TextBody = " Alerting text  " &  objItem.Name
      oMessage.Send

Next

Just configure the above scripts with windows task scheduler, If any of send port/ receive locations stopped/disabled will send alert to E-mails mentioned in   oMessage.To and before sending e-mail alert, script also enable to receive location / start the send port.

If you have any issue to configure this , please let me know.

Thanks,
-Gopal 




Biztalk Terminator

Instead of terminate script or download script. Biztalk team recently released the tool called Biztalk terminator. it is very useful for biztalk instance termination, Message download and We can easily integrate Biztalk messagebox viewer. this  can be downloaded from the below link. More info or download please follow the below link