0
J'ai ce code dans l'un de mes scripts PowerShell:Fonction paramètres ordre dans PowerShell
function callCommandWithArguments([String] $arg1, [String] $arg2)
{
[string]$pathToCommand = "C:\command.exe";
[Array]$arguments = "anArg", "-other", "$arg2", "$arg1";
# the real code is
# & $pathToCommand $arguments;
# but was not working, so I change it to debug
Write-Host $pathToCommand $arguments;
}
callCommandWithArguments("1", "2");
Comme les arguments commande est alors modifié dans le tableau $arguments
, je me attends à cette sortie:
C:\command.exe anArg -other 2 1
Mais à la place, je reçois un étrange:
C:\command.exe anArg -other 1 2
Est-ce que je manque quelque chose d'évident?
Grand merci! Je comprends maintenant ... –
@YannickBlondeau Content d'aider! –