BizTalk PowerShell Provider Start Stop Receive Location

Posted: August 22, 2017  |  Categories: BizTalk
Tags: PowerShell

I am writing this post as a reminder for me how to write a PowerShell Provider script. The example I attach stops a receive location and then starts it 1 minute later.

The BizTalkFactory PowerShell Provider is a PowerShell Snap-In for BizTalk Server 2006 R2, BizTalk Server 2009 and BizTalk Server 2010 that allows developers and administrators to easily automate routine and complex BizTalk administration tasks such as deploying applications, and managing configuration and run-time data using Windows PowerShell.

The installation media for BizTalk 2013 through 2016 includes the PowerShell Provider for BizTalk from the original Codeplex project.

Since leaving Datacom I don’t have access to their library of PowerShell scripts to consult. This is a bit annoying since I wrote most of them. Writing a PowerShell script the other day to stop and start a receive location, I became frustrated because I could not remember some of the syntaxes. Accessing the original Codeplex to access the help shows an annoying broken link.

Complaining about this  on Twitter , Coen Dikgraaf and Jerome Maes came to the rescue.

Without further ado here is a very simple example of a Powershell script that shows some of the cmdlets and syntax. Enjoy…

PowerShell Provider Script Example

#
# this script restarts a receive location
#
# The syntax to run it is like
# -File C:\Utilities\RestartReceiveLocation.ps1 -Application “Customer” -Receive_Location “Receive Location_Order_SFTP”
#
# It requires the powershell provider extensions to be on the server
#
###############################################################
# AND YOU CAN ONLY RUN THIS SCRIPT WITH A 32 BIT POWERSHELL
##################################################################
#

Param([string]$Application , [string]$Receive_Location)

#Set-ExecutionPolicy –ExecutionPolicy RemoteSigned

$PSScriptRoot=Split-Path -Parent -Path $MyInvocation.MyCommand.Definition

Write-host “Getting BizMgmtDb Server Name”
$btsConnectionString = “server=.;database=BizTalkMgmtDb;Integrated Security=SSPI”;
if ((Test-Path “hklm:SOFTWARE\Microsoft\Biztalk Server\3.0\Administration”) -eq $true)
{
Write-Output “Found registry entry for BizTalk Management DB.”
$btsDBServer = (Get-ItemProperty “hklm:SOFTWARE\Microsoft\Biztalk Server\3.0\Administration”).MgmtDBServer
$btsMgmtDB = (Get-ItemProperty “hklm:SOFTWARE\Microsoft\Biztalk Server\3.0\Administration”).MgmtDBName
$btsConnectionString = “server=”+$btsDBServer+”;database=”+$btsMgmtDB+”;Integrated Security=SSPI”
}

Write-Host “Loading Powershell provider for BizTalk snap-in”

$InitializeDefaultBTSDrive = $false
Add-PSSnapin –Name BizTalkFactory.Powershell.Extensions

Write-Host $btsDBServer

New-PSDrive -Name BizTalk -Root BizTalk:\ -PsProvider BizTalk -Instance $btsDBServer -Database BizTalkMgmtDb

Write-Host “Switch to the default” $Application “path”

Set-Location –Path BizTalk:\Applications\$Application\’Receive Locations’

Write-Host “Disabling” $Receive_Location
Disable-ReceiveLocation $Receive_Location
#Get-ChildItem $Receive_Location
Write-Host “Sleeping for 60 seconds”
Start-Sleep -s 60
Write-Host “Enabling” + $Receive_Location
Enable-ReceiveLocation $Receive_Location

#1 all-in-one platform for Microsoft BizTalk Server management and monitoring
turbo360

Back to Top