[Solved] Powershell Start-BitsTransfer error with some URL

Discussion in 'Scripting' started by migascalp, Jan 21, 2024.

  1. migascalp

    migascalp MDL Senior Member

    Sep 18, 2009
    459
    785
    10
    Hello
    2 examples to explain.
    Code:
    set "SetupFile=https://officecdn.microsoft.com/pr/wsus/setup.exe"
    call :DOWNLOAD %SetupFile% setup.exe
    goto :eof
    :DOWNLOAD
    powershell -Command "Start-BitsTransfer -Source '%1' -Destination '%2'"
    exit /b
    
    Work.

    Code:
    set "SetupFile=https://c2rsetup.officeapps.live.com/c2r/download.aspx?ProductreleaseID=ProPlusRetail&platform=x64&language=fr-fr&version=O16GA"
    call :DOWNLOAD %SetupFile% setup.exe
    goto :eof
    :DOWNLOAD
    powershell -Command "Start-BitsTransfer -Source '%1' -Destination '%2'"
    exit /b
    
    Does not work. Error message.

    On the other hand, in a Powershell window the URL works.
    Code:
    Start-BitsTransfer -Source 'https://c2rsetup.officeapps.live.com/c2r/download.aspx?ProductreleaseID=ProPlusRetail&platform=x64&language=fr-fr&version=O16GA' -Destination 'setup.exe'
    Also works if I use the 'curl' command.

    A solution ?
     
  2. abbodi1406

    abbodi1406 MDL KB0000001

    Feb 19, 2011
    17,281
    91,251
    340
    Code:
    set "SetupFile=https://c2rsetup.officeapps.live.com/c2r/download.aspx?ProductreleaseID=ProPlusRetail&platform=x64&language=fr-fr&version=O16GA"
    call :DOWNLOAD "%SetupFile%" setup.exe
    goto :eof
    :DOWNLOAD
    powershell -Command "Start-BitsTransfer -Source '%~1' -Destination '%2'"
    exit /b
    
     
  3. migascalp

    migascalp MDL Senior Member

    Sep 18, 2009
    459
    785
    10
    Works perfectly.
    THANKS.
     
  4. migascalp

    migascalp MDL Senior Member

    Sep 18, 2009
    459
    785
    10
    Thanks to whoever edited the title.
    I had forgotten to do it.