PS Script to Enable BizTalk Receive Location

We are encountering an issue in BizTalk server 2016, where a few running SFTP receive locations would stop after some time due to connectivity issues of their threshold. Therefore, I would like to share a PowerShell script to enable the receive location through Windows Task Scheduler.

Before executing the following script, please complete the following tasks:
a. Set the server name in the ConnectionString.
b. Set the value of ($hostname) to the host name used in the SFTP receive location.
c. Set the value of ($rcvLocation) to the receive location name.

# Import external assembly and create a new object

[void] [System.reflection.Assembly]::LoadWithPartialName(“Microsoft.BizTalk.ExplorerOM”)

$Catalog = New-Object Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer


 #BizTalk Config

$Catalog.ConnectionString = “SERVER=.;DATABASE=BizTalkMgmtDb;Integrated Security=SSPI”  #connectionstring for the BizTalkMgmtDb

$hostname = “BizTalkServerApplication” #hostname

$rcvLocation = “RL_GetAccReq_SQL” #receive location


#Function to retrieve the status of the specify receive location

function getStatus(){

   foreach ($receivePort in $catalog.ReceivePorts)


       foreach($receiveLoc in $receivePort.ReceiveLocations  | Where {$_.Name -eq $rcvLocation}){

            return $receiveLoc.Enable





#Function to enable the receive location

function enableReceiveLocation(){

   $location = get-wmiobject MSBTS_ReceiveLocation -Namespace ‘root\MicrosoftBizTalkServer’ -Filter “name=’${rcvLocation}‘”





 #check status of Receive Location

    $isEnabled = getStatus

    if($isEnabled -eq $false){

        #Restart host

        #Restart-Service -Displayname “BizTalk Service BizTalk Group : ${hostname}”


        #Enable receive location



        #Wait for few seconds

        Start-Sleep -s 30


Please keep in mind that the script above allows you to enable a single receive location for SFTP. However, you can set up multiple SFTP receive locations by repeating the same steps for each location in BizTalk.

Note that you need to use the BizTalk Admin Group user to create a Window Task Scheduler, and if the BizTalkMgmtDb database runs under a different user, please provide the username and password in the ConnectionString.

Post a comment

Leave a Comment

Scroll to Top