• Why you should reconsider using the wget alias in Powershell scripts if you’re running them on auto-provisioned VMs

    by  • November 2, 2014 • .net, powershell • 0 Comments

    The other day I was looking for a Powershell one-liner to get the content of a URL and came across this superuser post, which suggested to take a look into Invoke-WebRequest or wget (an alias of Invoke-WebRequest). My usage was to pull in the content of this text file during a build on a remote TeamCity build agent. For some context, these build agents are configured and automated by Chef.

    This approach was a little naive:

    $content = (wget $url).Content

    As when I kicked off the build I was surprised to see this…
    wget : The response content cannot be parsed because the Internet Explorer engine is not available, or Internet Explorer's first-launch configuration is not complete. Specify the UseBasicParsing parameter and try again.

    Urgh… so it’s dependant on IE and it looks like I should have gone through the first-launch wizard? Not such a good idea if you are bringing these boxes up in an automated manner. If you see this and you are using wget, you might want to consider using some of the sauce that Chocolatey uses to download it’s install script by creating an instance of a .NET WebClient i.e.

    (new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')

    In my case, I took my wget and replaced it with:

    $content = (new-object net.webclient).DownloadString($url)

    Which, though slightly more verbose, doesn’t have this dependency on IE, good for the fact I’m hoping I never need to remote onto these boxes.


    .NET developer at thetrainline.com, previously web developer at MRM Meteorite. Awarded a PhD in misbehaviour detection in wireless ad-hoc networks. A keen C# ASP.net developer bridging the gap with APIs and JavaScript frameworks, one web app at a time.


    Leave a Reply

    Your email address will not be published. Required fields are marked *