powershell-script
powershell-script copied to clipboard
Passing parameters to Powershell
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.
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.