Search code examples
windowspowershellcmd

Cmd to powershell


Hello guys and sirs i need a powershell command of this cmd command is not working in powershell Could anyone help me make this one as ps script?

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%

Solution

  • Only a few tweaks are needed:

    • curl -> curl.exe, to make sure that the executable by that name is invoked, rather than Windows PowerShell's (unfortunate) built-in curl alias, which refers to its Invoke-WebRequest cmdlet. (By contrast, there's no tar alias, so there's no strict need to use tar.exe, but it can't hurt.)

    • cd is a built-in alias for PowerShell's Set-Location cmdlet, which functions analogously to cmd.exe's cd with a single, unquoted argument representing the target directory; so while you could retain cd as-is in this case, for a more PowerShell-idiomatic reformulation of your code Set-Location -LiteralPath is used below.

    • cmd.exe's dynamic %RANDOM% variable, which returns a random number between 0 and 32767, must be emulated with a call to PowerShell's 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)"