question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Powershell 2.0 inline script does not support passing arguments

See original GitHub issue

The File Path-based script allows passing in arguments:

image

The Inline one does not, however:

image

This significantly reduces its usefulness when used in task groups that can automatically discover configurable inputs from arguments used in a script.

Relevant PR: https://github.com/Microsoft/vsts-tasks/pull/4578

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
chrispatcommented, Aug 7, 2017

The reason they are different is because you can simply put the variables in the inline script which should be a lot simpler than dealing with arguments. In the case of the file you have no option to do that.

1reaction
iyerusadcommented, Sep 7, 2017

@chrisrpatterson

The reason they are different is because you can simply put the variables in the inline script which should be a lot simpler than dealing with arguments

Alas, unless I am mistaken, this breaks ability to use data retrieved from Azure Key Vault task. Actually using inline script appears to break all capability to retrieve ANY secret variables.

  1. Use Azure Key Vault task to pull down a vault. image
  2. Attempt to reference secrets pulled in previous task, using a powershell/batch/shell task using inline option - unable to extract the Key vault data pulled down. image

No results:

2017-09-07T20:38:42.0319456Z ##[section]Starting: PowerShell Script
2017-09-07T20:38:42.0329255Z ==============================================================================
2017-09-07T20:38:42.0329255Z Task         : PowerShell
2017-09-07T20:38:42.0329255Z Description  : This is an early preview. Run a PowerShell script on Windows, macOS, or Linux.
2017-09-07T20:38:42.0329255Z Version      : 2.121.0
2017-09-07T20:38:42.0329255Z Author       : Microsoft Corporation
2017-09-07T20:38:42.0329255Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613736)
2017-09-07T20:38:42.0329255Z ==============================================================================
2017-09-07T20:38:43.0071563Z Generating script.
2017-09-07T20:38:43.0681597Z ##[command]"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -File "d:\a\_temp\2ea4c913-5aec-405e-b326-008e447c8ee2.ps1"
2017-09-07T20:38:45.2496213Z ##[section]Finishing: PowerShell Script
Read more comments on GitHub >

github_iconTop Results From Across the Web

Powershell 2.0 inline script does not support passing arguments
The File Path-based script allows passing in arguments: The Inline one does not, however: This significantly reduces its usefulness when ...
Read more >
PowerShell 2.0 and "The term 'Param' is not recognized as the ...
I receive the following error: The term 'Param' is not recognized as the name of a cmdlet, function, script file, or operable program....
Read more >
How-to: Pass parameters to a PowerShell script. - SS64
Pass arguments to a script or cmdlet by separating them with spaces: PS C:\> Get-ChildItem -Path $env:windir -Filter *.dll -Recurse. This can be...
Read more >
Functions - PowerShell | Microsoft Learn
PowerShell functions allow you to create tools that can be reused in scripts. ... Don't hardcode values; use parameters and variables.
Read more >
python run powershell script with arguments - You.com
and specifying the arguments as a sequence rather than a string is the recommended option. When running a script, it needs to be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found