I try to run a script
powershell -File somescript.ps1 -Arg1 $false -Arg2 $false -Arg3 $false
I keep getting
A positional parameter cannot be found that accepts argument '$false'.
- I really want to see each parameters name, not just pass values without knowing what it is
- there are more parameters availble in the script with default values so I dont need to specify them
any help appreciated
Arg1a[bool]or[switch]parameter? If it's a switch then PowerShell is treating-Arg1in your command as equivalent to-Arg1:$true(switch arguments don't take a separate value - the parameter name on its own assumes$true, or you separate with a colon rather than a space - e.g.-Arg:$false) so you've then got a dangling$falsestraight after the space that powershell doesn't know what to do with, which is probably what the error is trying to tell you...powershell.exe's-Fileparameter. The workaround - which is no longer necessary in PowerShell (Core) 7+ (pwsh.exe) - is to use the-Command(-c) parameter instead (which fundamentally changes the syntax rules). However, if the target script uses[switch]parameters, which is preferable, passing Boolean values explicitly is normally not needed. See the linked duplicate for details.&if by command line you mean generically, but the dupe link for #56551242 is what you want for cmd