Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 运行可执行文件的语法?_Powershell - Fatal编程技术网

Powershell 运行可执行文件的语法?

Powershell 运行可执行文件的语法?,powershell,Powershell,我正在尝试从PowerShell 3 ISE运行此命令: &"C:\inetpub\htpasswd.exe -bc C:\inetpub\wwwroot\xyz\password\passMD5.txt sm88555 sm88999" 但是得到这个错误: 无法识别为cmdlet、函数、脚本文件或可操作程序的名称。请检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试 我认为PowerShell在第一个空格后会停止正确计算它?iex-调用我在失败时使用的表达式(&F) $h

我正在尝试从PowerShell 3 ISE运行此命令:

&"C:\inetpub\htpasswd.exe -bc C:\inetpub\wwwroot\xyz\password\passMD5.txt sm88555 sm88999"
但是得到这个错误:

无法识别为cmdlet、函数、脚本文件或可操作程序的名称。请检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试

我认为PowerShell在第一个空格后会停止正确计算它?

iex-调用我在失败时使用的表达式(&F)

$htPassword = "C:\inetpub\htpasswd.exe"
$htParams = "C:\inetpub\wwwroot\xyz\password\passMD5.txt sm88555 sm88999"
Invoke-Expression -Command "$htPassword $htParams"
joel-b-fant可以很好地处理这两个问题,iex-Invoke表达式在&失败时使用

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

joel-b-fant很好地处理了这两个问题,呼叫接线员不会解释整个命令行/表达式。这就是调用表达式的用途。如果要使用调用运算符,请将参数与命令分开,并相互分开:

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

调用运算符不解释整个命令行/表达式。这就是调用表达式的用途。如果要使用调用运算符,请将参数与命令分开,并相互分开:

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

iex-调用表达式[-Command][]iex-调用表达式[-Command][]