批处理文件命令到 powershell 命令

batch file command to powershell command

我有一个运行良好的批处理(.bat 文件)命令。但是,我需要将它转换为 powershell 命令,并且需要通过 powershell 运行 它。我已经尝试过在网上找到的不同方法,但 none 似乎按照我想要的方式工作。

批处理命令:

java -jar xyz.jar -url https://xyz.abc.com -user xyz123 -passwordHash abchgfqwfjhd1232bfyevt7676 -clientId GFGFhjxgsVGGF -clientSecret GFhjdhjdhdGGGbfsilwueibJGBjg -input C:\abc\Newfolder\xyz\  -v >> %logfile%

到目前为止,我刚刚能够 运行 这个基本的 powershell 命令。有人可以帮忙吗?

Powershell 命令:

Start-Process -FilePath https://xyz.abc.com

也许这有帮助:

 $logFile = "C:\temp\logFile.txt"
 Invoke-Expression "java -jar xyz.jar -url https://xyz.abc.com -user xyz123 -passwordHash abchgfqwfjhd1232bfyevt7676 -clientId GFGFhjxgsVGGF -clientSecret GFhjdhjdhdGGGbfsilwueibJGBjg -input C:\abc\Newfolder\xyz\  -v " | Out-File $logFile

Invoke-Expressiondocu, be aware that Invoke-Expression should only be used if the string you're invoking is under your control. Another alternative is the & (call-operator), check this Whosebug ,解释了它们之间的区别。

希望对您有所帮助。