Close

Powershell script to enable/disable receive location

I had a situation in which I had to process a very large number of messages as an initial load. The messages had to be sent to a third-party webservice, but  I wanted to prevent the webservice from being overloaded. In that case you can build a sequential convoy, to send one message at a time. I didn’t want to build an orchestration for a one-time process though. That’s why I made a Powershell script that enables and disables the receive location in a configurable loop. Maybe not the nicest solution, but it solves my problem.

# Get the Receive Location of the specified name
$location = get-wmiobject msbts_receivelocation -Namespace ‘rootMicrosoftBizTalkServer’ -Filter “name=’RcvArticleInformationUpdate.MSMQ'”

# Initialize loop
$loop = 1

# Disable the Receive Location
$location.Disable()
“Disable Receive Location”

DO
{

“Starting Loop $loop”

# Enable the Receive Location
$location.Enable()
“Enable Receive Location”

# Wait for 1 minute
Start-Sleep -s 30

# Disable the Receive Location
$location.Disable()
“Disable Receive Location”

# Wait for 1 minute
Start-Sleep -s 90

$loop++

} While ($loop -le 5)