Last active
February 27, 2018 08:08
-
-
Save jhorsman/682386c4e901d77bed5662433446c9d0 to your computer and use it in GitHub Desktop.
Call a script with an array of arguments in PowerShell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @ECHO off | |
| ECHO The %~nx0 script args are... | |
| for %%I IN (%*) DO ECHO %%I |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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