1

I am trying to run this from the PowerShell 3 ISE:

&"C:\inetpub\htpasswd.exe -bc C:\inetpub\wwwroot\xyz\password\passMD5.txt sm88555 sm88999"

but get this error:

is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

I think PowerShell stops evaluating this correctly after the first space?

1
  • iex - Invoke-Expression [-Command] <string> [<CommonParameters>] Commented Nov 29, 2015 at 5:50

2 Answers 2

2

iex - Invoke-Expression I use when & fails

$htPassword = "C:\inetpub\htpasswd.exe"
$htParams = "C:\inetpub\wwwroot\xyz\password\passMD5.txt sm88555 sm88999"
Invoke-Expression -Command "$htPassword $htParams"

myeval handles both quite well by joel-b-fant

Sign up to request clarification or add additional context in comments.

Comments

2

The call operator doesn't interpret entire commandlines/expressions. That is what Invoke-Expression is for. Separate the arguments from the command (and from each other) if you want to use the call operator:

& "C:\inetpub\htpasswd.exe" -bc "C:\inetpub\wwwroot\xyz\password\passMD5.txt" "sm88555" "sm88999"

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.