Cmd 到 powershell

Cmd to powershell

大家好,先生们,我需要一个 powershell 命令,这个 cmd 命令在 powershell 中不起作用 谁能帮我把这个做成 ps 脚本?

cls
curl -LJOk "https://github.com/doktor83/SRBMiner-Multi/releases/download/0.8.9/SRBMiner-Multi-0-8-9-win64.zip"
tar -xvf SRBMiner-Multi-0-8-9-win64.zip
cd SRBMiner-Multi-0-8-9
SRBMiner-MULTI.exe --disable-gpu --algorithm verushash --pool eu.luckpool.net:3956 --wallet RTiE77wrw3oNc9Y5M99ckK5vvEppwErtg4.%RANDOM%

只需要进行一些调整:

  • curl -> curl.exe,以确保调用该名称的可执行文件,而不是 Windows PowerShell 的(不幸的)built-in curl alias,指的是它的 Invoke-WebRequest cmdlet。 (相比之下,没有 tar 别名,因此没有严格的使用 tar.exe 的必要,但它不会造成伤害。)

  • cd 是 PowerShell 的 Set-Location cmdlet 的 built-in 别名,其功能类似于 cmd.execd表示目标目录的单个不带引号的参数;因此,虽然在这种情况下您可以保留 cd as-is,但为了更 PowerShell-idiomatic 重新编写您的代码,下面使用 Set-Location -LiteralPath

  • cmd.exe的动态%RANDOM%变量,returns一个介于032767之间的随机数,必须模拟调用 PowerShell 的 Get-Random cmdlet, enclosed in $(..), the subexpression operator, so that the cmdlet's output can be used inside an expandable (double-quoted) string ("..."):

curl.exe -LJOk "https://github.com/doktor83/SRBMiner-Multi/releases/download/0.8.9/SRBMiner-Multi-0-8-9-win64.zip"
tar.exe -xvf SRBMiner-Multi-0-8-9-win64.zip
Set-Location -LiteralPath SRBMiner-Multi-0-8-9
SRBMiner-MULTI.exe --disable-gpu --algorithm verushash --pool eu.luckpool.net:3956 --wallet "RTiE77wrw3oNc9Y5M99ckK5vvEppwErtg4.$(Get-Random -Max 32767)"