Receive Location Action Module

Microsoft.BizTalk.Server.2016.ReceiveLocationAction.Task (WriteActionModuleType)

This module is used for performing operations on a receive location.

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityPublic
RunAsMicrosoft.BizTalk.ProbeAccount
InputTypeSystem.BaseData
OutputTypeSystem.CommandOutput

Member Modules:

ID Module Type TypeId RunAs 
Script WriteAction Microsoft.Windows.ScriptWriteAction Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
TimeoutSecondsint$Config/TimeoutSeconds$Timeout SecondsThis is the timeout (in seconds) after which execution of the script associated with the module is terminated if not yet completed.

Source Code:

<WriteActionModuleType ID="Microsoft.BizTalk.Server.2016.ReceiveLocationAction.Task" Accessibility="Public" RunAs="Microsoft.BizTalk.ProbeAccount" Batching="false">
<Configuration>
<xsd:element name="TargetComputer" type="xsd:string"/>
<xsd:element name="ReceiveLocationName" type="xsd:string"/>
<xsd:element name="TaskOption" type="xsd:string"/>
<xsd:element name="TimeoutSeconds" type="xsd:integer"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<WriteAction ID="Script" TypeID="Windows!Microsoft.Windows.ScriptWriteAction">
<ScriptName>Microsoft.BizTalk.Server.2016.EnableReceiveLocation.vbs</ScriptName>
<Arguments>$Config/TargetComputer$ "$Config/ReceiveLocationName$" $Config/TaskOption$</Arguments>
<ScriptBody><Script>
'Copyright (c) Microsoft Corporation. All rights reserved.
'*************************************************************************
' $ScriptName: "Enable/disable Receive Location" $
'
' Purpose - This script enable/disable a Receive Location.
'
' Parameters
' "TargetComputer" = the computer that we target this task
' "ReceiveLocationName" = the name of the receive location
' "Option" = this is the task option (enable/disable)
'
' $File: Microsoft.BizTalk.Server.2016.EnableReceiveLocation.vbs $
'
'*************************************************************************

Option Explicit

Dim oArgs
Dim strNamespace, strQuery
Dim strReceiveLocationName, strTargetComputer, strOption

Const EVENT_SOURCE = "Task enable or disable Receive Location"

'Event Type Constants
Const EVENT_TYPE_SUCCESS = 0
Const EVENT_TYPE_ERROR = 1
Const EVENT_TYPE_WARNING = 2
Const EVENT_TYPE_INFORMATION = 4

Set oArgs = WScript.Arguments
if oArgs.Count &lt; 3 Then
Wscript.Quit -1
End If

strTargetComputer = oArgs(0)
strReceiveLocationName = oArgs(1)
strOption = oArgs(2)
strNamespace = "\ROOT\MicrosoftBizTalkServer"
strQuery = "select * from MSBTS_ReceiveLocation where Name =""" &amp; Replace(strReceiveLocationName, "\", "\\") &amp; """"

ExecActionOnReceiveLocation

Sub ExecActionOnReceiveLocation()
Dim strMessage
Dim objInstSet, objInst
On Error Resume Next
Set objInstSet = GetWMICollection(strTargetComputer, strNamespace, strQuery)

'Check for error condition before continuing.
If Err &lt;&gt; 0 Then
PrintWMIErrorThenExit Err.Description, Err.Number
End If

'If found, execute action, otherwise print error and end.
If objInstSet.Count &gt; 0 then
For Each objInst in objInstSet
Select Case strOption
Case "1"
objInst.Enable
strMessage = "The Receive Location was successfully enabled."
Case "2"
objInst.Disable
strMessage = "The Receive Location was successfully disabled."
End Select
If Err &lt;&gt; 0 Then
PrintWMIErrorThenExit Err.Description, Err.Number
End If
WScript.Echo
Next
Else
WScript.Echo "No Receive Location was found matching that Name."
End If
End Sub

Function GetWMICollection(TargetComputerToUse, strNamespace, strQuery)
Dim WbemSrv, WbemObjectSet
Set WbemSrv = Getobject("winmgmts:{impersonationLevel=impersonate}!\\" &amp; TargetComputerToUse &amp; strNamespace)
Set WbemObjectSet = WbemSrv.ExecQuery(strQuery)
Set GetWMICollection = WbemObjectSet
End Function

'This subroutine deals with all errors using the WbemScripting object. Error descriptions
'are returned to the user by printing to the console.
Sub PrintWMIErrorThenExit(strErrDesc, nErrNum)
On Error Resume Next
Dim objWMIError : Set objWMIError = CreateObject("WbemScripting.SwbemLastError")

If ( TypeName(objWMIError) = "Empty" ) Then
WScript.Echo strErrDesc &amp; " (HRESULT: " &amp; Hex(nErrNum) &amp; ")."
Else
WScript.Echo objWMIError.Description &amp; "(HRESULT: " &amp; Hex(nErrNum) &amp; ")."
Set objWMIError = Nothing
End If

'bail out
WScript.Quit 0
End Sub


'=================================================================================
' Publish resulting performance data / Create events
'=================================================================================

Sub CreateEvent(strSource, lngEventID, lngEventType, strMsg, strSrcComputer)
CreateEventEx strSource, lngEventID, lngEventType, strMsg, strSrcComputer, True
End Sub

Sub CreateReportEvent(strSource, lngEventID, lngEventType, strMsg, strSrcComputer)
CreateEventEx strSource, lngEventID, lngEventType, strMsg, strSrcComputer, False
End Sub

Sub CreateEventEx(strSource, lngEventID, lngEventType, strMsg, strSrcComputer, blnIncScriptName)
Dim oAPI
Set oAPI = CreateObject("Mom.ScriptAPI")
Call oAPI.LogScriptEvent(strSource, lngEventID, lngEventType, strMsg)
End Sub
</Script></ScriptBody>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="Script"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.CommandOutput</OutputType>
<InputType>System!System.BaseData</InputType>
</WriteActionModuleType>