locked
Script returned 503 error server unavailable RRS feed

  • Question

  • Hi, 

    I have tried manually go to web url and i can download the ebook pdf from the iste. 

    but the below script that i used giving 503 error: below is the script and error details.

    Please let me know if you have any idea. i have tried in all the ways. but no good luck:(

    Script:

    ############################################################### 
    # Eric Ligmans Amazing Free Microsoft eBook Giveaway 
    # https://blogs.msdn.microsoft.com/mssmallbiz/2017/07/11/largest-free-microsoft-ebook-giveaway-im-giving-away-millions-of-free-microsoft-ebooks-again-including-windows-10-office-365-office-2016-power-bi-azure-windows-8-1-office-2013-sharepo/
    # Link to download list of eBooks 
    # http://ligman.me/2sZVmcG 
    # Thanks David Crosby for the template (https://social.technet.microsoft.com/profile/david%20crosby/)
    ############################################################### 
    $dest = "C:\downloads\ebooks" 
     
    # Download the source list of books 
    $downLoadList = "http://ligman.me/2tk1D2V" 
    $bookList = Invoke-WebRequest $downLoadList 
     
    # Convert the list to an array 
    [string[]]$books = "" 
    $books = $bookList.Content.Split("`n") 
    # Remove the first line - it's not a book 
    $books = $books[1..($books.Length -1)] 
    $books # Here's the list 
     
    # Download the books 
    foreach ($book in $books) { 
        $hdr = Invoke-WebRequest $book -Method Head 
        $title = $hdr.BaseResponse.ResponseUri.Segments[-1] 
        $title = [uri]::UnescapeDataString($title) 
        $saveTo = $dest + $title 
        Invoke-WebRequest $book -OutFile $saveTo 

    Error:

    Invoke-WebRequest : The remote server returned an error: (503) Server Unavailable.
    At C:\temp\ELigman_DownloadAll_Powershell.ps1:23 char:12
    +     $hdr = Invoke-WebRequest $book -Method Head
    +            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
        + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

    Regards,

    Mokesh.

    • Moved by Bill_Stewart Wednesday, September 13, 2017 8:56 PM This is not "fix/debug/rewrite my script for me" forum
    Thursday, July 20, 2017 5:12 PM

All replies

  • To download any of these eBooks just do this:

    $wc = New-Object System.Net.WebClient
    $wc.DownloadFile('http://ligman.me/1IW1oab', 'd:\test6\ebook.pdf')

    To download the list:

    $wc.DownloadFile('http://ligman.me/2sZVmcG ', 'd:\test6\ebook.txt')


    \_(ツ)_/

    Thursday, July 20, 2017 5:28 PM