Download all free ebooks from Microsoft using Powershell

This script is not very efficient (downloads everything twice, working on that still BUT)

 

If you’d like to conveniently download all the ebooks Eric Ligman has been kind enough to share out… You can run this in PowerShell 3.0 or higher (It was tested in Windows 10 – Powershell 5 but should work in earlier versions)

 

# URL to website

$link=’https://blogs.msdn.microsoft.com/mssmallbiz/2016/07/10/free-thats-right-im-giving-away-millions-of-free-microsoft-ebooks-again-including-windows-10-office-365-office-2016-power-bi-azure-windows-8-1-office-2013-sharepoint-2016-sha/’

# Download website page

$result=Invoke-WebRequest -Uri $link

# Get list of all links with Eric’s Short URL

$URIList=$result.links | where { $_.OuterHTML -match ‘ligman.me’ }
Foreach ($URI in $URIList)
{
# Get the Hyperlink to the book

$DownloadLink=$URI.href

# Download the book

$file=Invoke-WebRequest -uri $DownloadLink

# Get the actual filename from Content

$filename=($File.Baseresponse.ResponseURI.AbsolutePath.split(‘/’)[-1])

# Here is the stupid part I didn’t figure out yet – RE download the book

Invoke-WebRequest -uri $Downloadlink -outfile $Filename
}

 

This will take a while and it’s NOT very efficient (Invoke-WebRequest gives you progress but it’s slow) but you don’t need to sit and watch.   Warning… this may hit your bandwidth so try to do it on your personal account…. not the company internet

Leave a Reply