Skip to content

Instantly share code, notes, and snippets.

@mgreenegit
Last active May 23, 2018 19:25
Show Gist options
  • Save mgreenegit/b80ddd089677f92f56f5 to your computer and use it in GitHub Desktop.
Save mgreenegit/b80ddd089677f92f56f5 to your computer and use it in GitHub Desktop.
Get latest WMF5 and quietly install, reboot suppressed
# Use shortcode to find latest TechNet download site
$confirmationPage = 'http://www.microsoft.com/en-us/download/' + $((invoke-webrequest 'http://aka.ms/wmf5latest' -UseBasicParsing).links | ? Class -eq 'mscom-link download-button dl' | % href)
# Parse confirmation page and look for URL to file
$directURL = (invoke-webrequest $confirmationPage -UseBasicParsing).Links | ? Class -eq 'mscom-link' | ? href -match 'Win8.1AndW2K12R2-KB3134758-x64.msu' | % href | select -first 1
# Download file to local
$download = invoke-webrequest $directURL -OutFile $env:Temp\wmf5latest.msu
# Install quietly with no reboot
if (test-path $env:Temp\wmf5latest.msu) {
start -wait $env:Temp\wmf5latest.msu -argumentlist '/quiet /norestart'
}
else { throw 'the update file is not available at the specified location' }
# Clean up
Remove-Item $env:Temp\wmf5latest.msu
# Assumption is that the next likely step will be DSC config, starting with xPendingReboot to finish install
<#
File names:
W2K12-KB3134759-x64.msu
Win7AndW2K8R2-KB3134760-x64.msu
Win7-KB3134760-x86.msu
Win8.1AndW2K12R2-KB3134758-x64.msu
Win8.1-KB3134758-x86.msu
#>
@joeyaiello
Copy link

Check out my fork. Fixed it for 'Win8.1AndW2K12R2' instead of WindowsBlue

@johnmccrae
Copy link

I have a rookie question: How were you able to discover that link to Akamai servers? I have been through the webpage lightly a couple of times and didn't see it. Or is it Microsoft insider Foo?

I REALLY like this tool. It works great and saves me a ton of time. I'd love to use the webpage scraping for other sites. Thanks for posting this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment