windowspowershellboostwebrequest

How to download and run installer with PowerShell?


I am trying to download and execute an installer (of Boost 1.74) on Windows PowerShell for a CI system:

I am using Invoke-WebRequest and after that simply execute the program. However it tells me that file is corrupt. I tried several times and I don't think the file is corrupt but perhaps there is a problem with the permissions.

$ Invoke-WebRequest 'https://downloads.sourceforge.net/project/boost/boost-binaries/1.74.0/boost_1_74_0-msvc-14.2-64.exe' -OutFile 'boost_1_74_0-msvc-14.2-64.exe'
$ ./boost_1_74_0-msvc-14.2-64.exe
Program 'boost_1_74_0-msvc-14.2-64.exe' failed to run: The file or directory is corrupted and unreadableAt line:323 
char:1
+ ./boost_1_74_0-msvc-14.2-64.exe
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
At line:323 char:1
+ ./boost_1_74_0-msvc-14.2-64.exe
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [], ApplicationFailedException
    + FullyQualifiedErrorId : NativeCommandFailed

How can I make sure the installer is executed here? What am I doing wrong?


NOTE: I am using this link (that according to the comments just points to a small text file with another web address) because it is the one used by Chocolatey installer.

# Install 64 bit binaries
Install-ChocolateyPackage `
    -packageName 'boost-msvc-14.2' `
    -installerType 'exe' `
    -silentArgs '/VERYSILENT' `
    -url64bit 'https://downloads.sourceforge.net/project/boost/boost-binaries/1.74.0/boost_1_74_0-msvc-14.2-64.exe' `
    -checksum64 74229a45b1e13f05c5bbdca7a268ac7723d97c33bec209e5f669b6cb3ffaeab6 `
    -checksumType64 sha256

Solution

  • To add to Someone's helpful answer: