powershell-script icon indicating copy to clipboard operation
powershell-script copied to clipboard

Passing parameters to Powershell

Open elanzini opened this issue 3 years ago • 2 comments

Is this functionality already built in?

Example usage:

# CreateFile.ps1
Param (
  $Path
)
New-Item $Path # Creates a new file at $Path.
Write-Host "File $Path was created"
./CreateFile.ps1 -Path './newfile.txt' # File ./newfile.txt was created.

elanzini avatar Jun 02 '22 08:06 elanzini

I assume the argument needs to be provided to the Command object which runs the script?

Unfortunately, there is no way to currently add additional arguments, but it would be relatively easy to implement given that there is already an args object in PsScriptBuilder that you could push additional arguments to.

cfsamson avatar Jun 04 '22 16:06 cfsamson