We are facing problem in BizTalk server 2016 that few of running SFTP Receive location would be stopped after some time due to sftp connectivity issue of their threshold so I am going to share PowerShell script to enable receive location by window task scheduler.
Before execute following script Please do following task
a. Set Server name in ConnectionString
b. Set ($hostname) host name value that is using in SFTP Receive location
c. Set ($rcvLocation) 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}'"
[void]$location.Enable()
[void]$Catalog.Refresh()
}
#check status of
Receive Location
$isEnabled
= getStatus
if($isEnabled -eq
$false){
#Restart
host
#Restart-Service
-Displayname "BizTalk Service BizTalk Group : ${hostname}"
#Enable
receive location
enableReceiveLocation
#Wait for
few seconds
Start-Sleep
-s 30
}
In above script you can enable one receive location but you can also go for more than one SFTP receive location by repeating same task for another BizTalk SFTP Receive location.
Note: Use BizTalk Admin Group user to create Window Task Scheduler and If BizTalkMgmtDb database run under different user then please define Username and possword it in ConnectionString.
Nice article, Thanks for sharing !
ReplyDeleteThe worked . Keep updating Biztalk online training Bangalore
ReplyDeleteTried it for Biztalk 2010 script completed but the receive location was still disabled. Would this work for BizTalk 2010?
ReplyDeleteI have tested in BizTalk 2016 and please let me know if any error in biztalk 2010
DeleteExcellent article and this helps to enhance your knowledge regarding new things. Waiting for more updates.
ReplyDeleteAngularJS Course in Chennai
Angularjs Training Institute in Chennai
AngularJS Online Training
Great post!!! Thanks for sharing this wonderful blog with us...
ReplyDeleteDigital Marketing in India
Scope of Digital Marketing