Skip to content

Instantly share code, notes, and snippets.

@jhorsman
Last active February 27, 2018 08:08
Show Gist options
  • Select an option

  • Save jhorsman/682386c4e901d77bed5662433446c9d0 to your computer and use it in GitHub Desktop.

Select an option

Save jhorsman/682386c4e901d77bed5662433446c9d0 to your computer and use it in GitHub Desktop.
Call a script with an array of arguments in PowerShell
@ECHO off
ECHO The %~nx0 script args are...
for %%I IN (%*) DO ECHO %%I
# This is an alternative way of calling .\echo.bat --hello=World --bonjour=Monde
# also see https://octopus.com/blog/dynamic-argument-list-when-calling-executable-from-powershell
$script = ".\echo.bat"
$args = @()
$args += "--hello"
$args += "World"
$args += "--bonjour"
$args += "Monde"
& $script $args
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment