Hi All,
This is the continuation for the below blog post.
once you exported the bindings , you can copy the entire folder and try to run the below script.
In the same script folder.
If any error occurs , it halts the processing.
#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
$inputFiles = “$dir\Bindings\”
$LogFilepath = “$Dir\Logs\”
if(!(Test-Path $LogFilepath))
{
New-Item -ItemType directory -Path $LogFilepath
}
$LogFile = “$LogFilepath\ImportLogfile.txt”
TRY
{
Get-ChildItem -path $inputFiles -Filter *.xml -Recurse |ForEach-Object -Process{
$Actfilepath = $_.FullName
$filename = $_.BaseName
$LogDateTime = get-date
Write-host “***Starting Importing of Bindings for Application : $filename in” + $inputFiles “folder” -ForegroundColor Cyan
$run = “BTSTask.exe ImportBindings /Source:$Actfilepath /ApplicationName:$filename /Server:$MgmtDbServerName /Database:$MgmtDbname”
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 : $filename in ” + $inputFiles “folder” -ForegroundColor green
}
}
CATCH
{
$_.Exception.Message|Add-Content $LogFile
}
Let me know if you have any questions.
Regards,
Chaitanya