powershell - 运行可执行文件的语法?

标签 powershell

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

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

但是得到这个错误:

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.



我认为PowerShell在第一个空格后会停止正确评估此值?

最佳答案

iex-当&失败时使用的Invoke-Expression

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

myeval通过joel-b-fant很好地处理了这两个问题

关于powershell - 运行可执行文件的语法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33979643/

相关文章:

powershell - 尝试通过 Powershell 脚本在 IIS 中创建网站

powershell - 为什么在命令提示符和Powershell的底部有这么多的空格(回车)?

powershell - 超时执行语句?

Powershell 检查 IIS 中是否存在 MIME

Powershell - 字符串内的正斜杠

powershell - 从Jenkins PowerShell构建步骤中调用的PowerShell脚本无限期挂起

powershell - 如何使用PowerShell参数

powershell - 在 PowerShell 中从 CNAME 解析主机名

shell - 为什么 `help format-list` 与 `format-list | help` 不一样?

用于设置 pagefile.sys 大小的 PowerShell 脚本