I have a batch file (runPowerShell.bat) with the following line:
Powershell.exe -ExecutionPolicy ByPass -File %psFile% %2 %3 %4 %5
%1 is psFile in which the powershell file is passed in
%2 is another argument i intend to pass later
%3 is the arg i wanna print for now
The powershell file (scriptWrapper.ps1) contains this:
param($App_input)
$Script = "$($args[2])" #%2 for process or sync
write-host $Script
There is another PowerShell file called
Process.ps1
that i wish to pass as %3 argument, meaning $args[2]
if i say write-host "$args[2]"
it prints like this:
Process.ps1[2]
so it kinda works but i dont want the positional parameter with it, so I followed this thread for guidance, and the solution ($($args[2])
) makes sense, but I am unsure why its not working for me
accessing the $args array in powershell
it prints nothing: