0

As the title says, any argument passed to a PowerShell script that starts with a '/' is replaced with True.

For a script

param (
    [string]$wd = ""
)
echo $wd

And run with .\script.ps1 -wd "/etc/xyz", the output is True instead of the expected /etc/xyz. I was unable to find this behavior documented elsewhere, except for a similar issue in vbscript.

How can I get the string as-is?

Hele
  • 1,558
  • 4
  • 23
  • 39
  • 2
    Can't reproduce. What is you Powershell version? check "$PSVersionTable.PSVersion" – Megabeets Oct 07 '17 at 08:41
  • My PS version is 5.1.15063.632. I think it may have something to do with what PS2EXE did. I'll take a look at that. – Hele Oct 07 '17 at 08:46
  • You have a new version of Powrshell so I guess it has nothing to do with PS. Update us with further information :) – Megabeets Oct 07 '17 at 09:01
  • 2
    Try to retype your command line (and function), excluding known copy-paste issues as with [non-standard dash characters](https://stackoverflow.com/questions/43776009/powershell-script-error-the-string-is-missing-the-terminator/43776630). If it still doesn't work put the whole function in your question as with the current information the issue can't be reproduced. – iRon Oct 08 '17 at 07:49

0 Answers0