1

In an Azure devops pipeline, I am trying to execute a powershell script from a file.

- task: AzurePowerShell@5
  displayName: 'AzurePowershell script'
    inputs:
      azureSubscription: 'MyServiceConnection'
      ScriptType: FilePath
      ScriptPath: '$(System.DefaultWorkingDirectory)/path-to-script.ps1'
      ScriptArguments:  -firstParam "test"
      azurePowerShellVersion: LatestVersion

The issue is that I keep getting the following error:

Missing argument in parameter list.
At D:\a\_temp\a05fb35e-757c-4a3a-8729-*******.ps1:48 char:60
+ . 'D:\a\1\s\path-to-script.ps1' -firstParam "test"
+                                                            ~
The string is missing the terminator: ".
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : MissingArgument

I simplified my script to the point of having only a Write-Host inside to be sure it did not come from it, but at the end the goal is to use the pre-deployment script provided by microsoft for Azure data factories here.

param
(
   [parameter(Mandatory = $false)] [String] $firstParam
)

Write-Host $firstParam

I also tried using a PowerShell@2 and AzurePowerShell@4 tasks instead of the AzurePowerShell@5 and there it worked. So the problem seems to be only when using AzurePowerShell@5.

Do you have an idea of what I am doing wrong ?

olivier
  • 133
  • 3
  • 11
  • 1
    Hi olivier; it would probably help if you could also paste in the problem powershell script – Vince Bowdren Dec 21 '21 at 17:04
  • Hello Vince, thank you for your reply. I updated the question but not sure the script will be of great help. – olivier Dec 21 '21 at 17:14
  • 2
    I suggest examining your YAML file for hidden control characters. See [this answer](https://stackoverflow.com/a/68328388/45375) (function `Debug-String`) for a way to do that. Note that the `~` that indicates the position of the syntax error is way past the end of the command line. – mklement0 Dec 21 '21 at 17:23

0 Answers0