Ravindar, Biztalk Developer and Administrator

Just another BizTalk blog

Disable all artifacts of a particular Biztalk application using powershell

the following code disables all recieve locations for a particular specified BizTalk application named “MyBizApp”

Function Invoke-BizTalkEOM
$BizTalkConnectionString = "SERVER=.;DATABASE=BizTalkMgmtDb;Integrated Security=SSPI"
if ( ( Test-Path "HKLM:SOFTWARE\Microsoft\Biztalk Server\3.0\Administration" ) -eq $true )
 $BizTalkMgmtDBServer = ( Get-ItemProperty "HKLM:SOFTWARE\Microsoft\Biztalk Server\3.0\Administration" ).MgmtDBServer
 $BizTalkMgmtDBName = ( Get-ItemProperty "HKLM:SOFTWARE\Microsoft\Biztalk Server\3.0\Administration" ).MgmtDBName
 $BizTalkConnectionString = "SERVER=$BizTalkMgmtDBServer;DATABASE=$BizTalkMgmtDBName;Integrated Security=SSPI"
$BizTalkCatalogExplorer = New-Object Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer
$BizTalkCatalogExplorer.ConnectionString = $BizTalkConnectionString
return $BizTalkCatalogExplorer
$BizTalkCatalogExplorer = Invoke-BizTalkEOM
 $BizTalkApplication = $BizTalkCatalogExplorer.Applications[$name]
 $BizTalkApplication.Stop([Microsoft.BizTalk.ExplorerOM.ApplicationStopOption] ("DisableAllReceiveLocations"))

if you want to disable other artifacts also, you can add parameters like below

$BizTalkApplication.Stop([Microsoft.BizTalk.ExplorerOM.ApplicationStopOption] ("DisableAllReceiveLocations","UnenlistAllOrchestrations","UnenlistAllSendPortGroups","UnenlistAllSendPorts","UndeployAllPolicies"))

July 5, 2013 Posted by | Powershell with Biztalk | Leave a comment

Get Biztalk serviceInstance details with Powershell

To get all service instance details of Acitive/readytorun/suspended(resumable and non resumable), dehydreated, use following command

Get-WmiObject -Class "MSBTS_ServiceInstance" -Namespace 'root\MicrosoftBizTalkServer' | Where-Object { $_.Item -match "$Name" -and $_.Item -ne "" -and ($_.ServiceStatus -eq "1" -or $_.ServiceStatus -eq "2" -or $_.ServiceStatus -eq "4" -or $_.ServiceStatus -eq "8" -or $_.ServiceStatus -eq "16" -or $_.ServiceStatus -eq "32")  }

it will display all service instances with following details for every instance


And if you want to know the count of all Biztalk application’s current Acitive/readytorun/suspended(resumable and non resumable), dehydreated messages, then use following command

$a=Get-WmiObject -Class "MSBTS_ServiceInstance" -Namespace 'root\MicrosoftBizTalkServer' | Where-Object { $_.Item -match "$Name" -and $_.Item -ne "" -and ($_.ServiceStatus -eq "1" -or $_.ServiceStatus -eq "2" -or $_.ServiceStatus -eq "4" -or $_.ServiceStatus -eq "8" -or $_.ServiceStatus -eq "16" -or $_.ServiceStatus -eq "32") } | measure

And if you want to get the number of service instance for a specific biztalk application, then use following, just replace the application name between the 2 star symbols in the parameter value for  Assembly name

$_.AssemblyName -like "*MyApplication*"

with your appropriate Biztalk application name

just similar to below

$a=Get-WmiObject -Class "MSBTS_ServiceInstance" -Namespace  root\MicrosoftBizTalkServer' | Where-Object { $_.Item -match "$Name" -and $_.Item -ne "" -and ($_.ServiceStatus -eq "1" -or $_.ServiceStatus -eq "2" -or $_.ServiceStatus -eq "4" -or $_.ServiceStatus -eq "8" -or $_.ServiceStatus -eq "16" -or $_.ServiceStatus -eq "32") -and $_.AssemblyName -like "*MyApplication*" } | measure


July 5, 2013 Posted by | Powershell with Biztalk | Leave a comment