Hi All,
You can export BizTalk Application bindings by using the below PowerShell script.
Simply give the application Names and it creates folder called Input files in your script folder incase if it does not exists and copies the files to that folders.
#region WriteLog function
function WriteLog($LogMessage, $LogDateTime, $LogType)
{
write-host
“$LogType, [“+ $LogDateTime +”]: “+ $LogMessage | Add-Content -Path $MainLogFilepath
}
$BiztalkSrvInfo = @{
‘MgmtDbname’=Get-CimInstance MSBTS_GroupSetting -namespace root\MicrosoftBizTalkServer|select MgmtDbName
‘MgmtDbServerName’=Get-CimInstance MSBTS_GroupSetting -namespace root\MicrosoftBizTalkServer|select MgmtDbServerName
}
$Obj = New-Object -TypeName PSObject -Property $BiztalkSrvInfo
$MgmtDbServerName = $Obj.MgmtDbServerName.MgmtDbServerName
$MgmtDbname = $Obj.MgmtDbname.MgmtDbName
$scriptpath = $MyInvocation.MyCommand.Path
$dir = Split-Path $scriptpath
$BindingFileDestinationPath = “$dir\Bindings\”
if(!(Test-Path $BindingFileDestinationPath))
{
New-Item -ItemType directory -Path $BindingFileDestinationPath
}
$LogFilepath = “$Dir\Logs\”
if(!(Test-Path $LogFilepath))
{
New-Item -ItemType directory -Path $LogFilepath
}
$LogFile = “$LogFilepath\ExportLogfile.txt”
$ApplicationObj = “Application1″,” Application2″,” Application3 ” # give the list of Application Names here that you want to export
TRY
{
$ApplicationObj |ForEach-Object -Process{
$ApplicationName = $_
$BindingFilePath = $BindingFileDestinationPath + $ApplicationName + “.xml”
$LogDateTime = get-date
Write-host “***Starting Extracting of Bindings for Application : $ApplicationName in” + $BindingFileDestinationPath “folder” -ForegroundColor Cyan
$run = “BTSTask.exe ExportBindings /Destination:’$BindingFilePath’ /ApplicationName:’$ApplicationName'”
Invoke-Expression $run | Add-Content $LogFile
if ($LASTEXITCODE -eq 1)
{
$LogMessage = throw $_.Exception.Message
}
$LogDateTime = get-date
Write-host “Finished Extracting of Bindings for Application : $ApplicationName in ” + $BindingFileDestinationPath “folder” -ForegroundColor green
}
}
CATCH
{
$_.Exception.Message|Add-Content $LogFile
}
Regards,
Chaitanya