Run powershell script on Devops with paramter

Yamina Jabeen 61 Reputation points
2022-07-06T07:00:49.413+00:00

We have created below script which is exporting send port details from binding file post deployment and then comparing the send port name from a csv lookup sheet we are exporting a new csv file having some interface details.

so the script is working fine when we are running on the server but we are trying to run the same script in azure devops pipeline mentioned the script path and argument then it failing with below error.

Script running fine in server:

$finalBinding = [xml](Get-Content 'D:\agent\BIZTALK_DEPLOY1\r17\a/_BOS.DMS.Parts.Master/drop/Binding.xml')
$finalBinding.BindingInfo.SendPortCollection.SendPort.Name | out-file "C:\Script\test.csv"
import-csv "C:\Script\test.csv" -Header SendPort | sort SendPort | export-csv "C:\Script\output.csv" -NoTypeInformation
Remove-Item –path "C:\Script\test.csv"

$BindingData = Import-Csv -Path "C:\Script\output.csv"
$LookupData = Import-Csv -Path "C:\Script\Interfacedetails.csv"
$UserOutput = @()

ForEach ($name in $BindingData)  
{  

    $userMatch = $LookupData | where {$_.SendPort -eq $name.SendPort}  
    If($userMatch)  
    {  
        $UserOutput += New-Object PsObject -Property @{InterfaceName=$userMatch.InterfaceName;ApplicationTo=$userMatch.ApplicationTo;ApplicationFrom =$userMatch.ApplicationFrom;InterfaceID=$userMatch.InterfaceID;DataObject=$userMatch.DataObject}  
    }  

}  

$UserOutput | export-csv "C:\Script\FILE.csv" -NoTypeInformation

Import-CSV C:\Script\FILE.csv | Select-Object InterfaceName, InterfaceID, DataObject, ApplicationFrom, ApplicationTo | Export-CSV C:\Script\ExportedCSV\Final.csv -NoTypeInformation
Remove-Item –path "C:\Script\FILE.csv"
Remove-Item –path "C:\Script\output.csv"

running the same script with Argument

$finalBinding = [xml](Get-Content –path $bindingpath)
$finalBinding.BindingInfo.SendPortCollection.SendPort.Name | out-file "C:\Script\test.csv"
import-csv "C:\Script\test.csv" -Header SendPort | sort SendPort | export-csv "C:\Script\output.csv" -NoTypeInformation
Remove-Item –path "C:\Script\test.csv"

$BindingData = Import-Csv -Path "C:\Script\output.csv"
$LookupData = Import-Csv -Path "C:\Script\Interfacedetails.csv"
$UserOutput = @()

ForEach ($name in $BindingData)  
{  

    $userMatch = $LookupData | where {$_.SendPort -eq $name.SendPort}  
    If($userMatch)  
    {  
        $UserOutput += New-Object PsObject -Property @{InterfaceName=$userMatch.InterfaceName;ApplicationTo=$userMatch.ApplicationTo;ApplicationFrom =$userMatch.ApplicationFrom;InterfaceID=$userMatch.InterfaceID;DataObject=$userMatch.DataObject}  
    }  

}  

$UserOutput | export-csv "C:\Script\FILE.csv" -NoTypeInformation

Import-CSV C:\Script\FILE.csv | Select-Object InterfaceName, InterfaceID, DataObject, ApplicationFrom, ApplicationTo | Export-CSV C:\Script\ExportedCSV\Final.csv -NoTypeInformation
Remove-Item –path "C:\Script\FILE.csv"
Remove-Item –path "C:\Script\output.csv"

I have declared the variable for $bindingpath = $(System.DefaultWorkingDirectory)/_BOS.DMS.Parts.Master/drop/Binding.xml

But its failing with below error:

Formatted command: . 'C:\Script\powershellscript.ps1' System.DefaultWorkingDirectory/_BOS.DMS.Parts.Master/drop/Binding.xml
2022-07-05T11:09:43.7113613Z ========================== Starting Command Output ===========================
2022-07-05T11:09:43.7250585Z ##[command]"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\agent\BIZTALK_DEPLOY1_temp\9b6ede3b-af5a-4813-9fc9-9d343c347be2.ps1'"
2022-07-05T11:09:44.0505059Z At C:\Script\powershellscript.ps1:24 char:15
2022-07-05T11:09:44.0505593Z + Remove-Item –path C:\Script\output.csv
2022-07-05T11:09:44.0505849Z + ~~~~~~~~~~~~~~~~~~~~~~~~~~
2022-07-05T11:09:44.0506103Z The string is missing the terminator: ".
2022-07-05T11:09:44.0506460Z + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
2022-07-05T11:09:44.0507271Z + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString

please help me to resolve the issue.

BizTalk Server
BizTalk Server
A family of Microsoft server products that support large-scale implementation management of enterprise application integration processes.
389 questions
Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. Limitless Technology 39,916 Reputation points
    2022-07-07T07:28:54.927+00:00

    Hello YaminaJabeen-0096,

    Since the question is related to scripting of Microsoft BizTalkI we would recommend you to get in touch with the specific community for that product at:

    https://techcommunity.microsoft. om/t5/biztalk-server/bd-p/BizTalkServer

    This way, the community will be more experience and able to provide expert advice of your question.

    ---------------------------------------------------------------------------------------------------------------------------------------

    --If the reply is helpful, please Upvote and Accept as answer--


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.