Skip to content

Instantly share code, notes, and snippets.

@Darkbat91
Last active May 15, 2017 23:48
Show Gist options
  • Save Darkbat91/89c26989ef6526960306d032ce9a4d7f to your computer and use it in GitHub Desktop.
Save Darkbat91/89c26989ef6526960306d032ce9a4d7f to your computer and use it in GitHub Desktop.
# http://boxstarter.org/launch/Boxstarter.WebLaunch.Application?noreboot=1&package=https://gist.githubusercontent.com/Darkbat91/89c26989ef6526960306d032ce9a4d7f/raw/
#https://tinyurl.com/WCRYFix
<#
The MIT License (MIT)
Copyright (c) 2016 Warren F.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
#>
#Re structured code from https://github.com/RamblingCookieMonster/PSDepend @RamblingCookieMonster
# Modified for backwards compatibility with PS2
function Get-PSWindowsUpdate
{
param(
[string]$Path = $( Join-Path ([environment]::GetFolderPath('Programfiles')) 'WindowsPowerShell\Modules')
)
#Nuget requires DotNet4 Installed from Boxstarter
#Test-Dotnet
$ExistingProgressPreference = "$ProgressPreference"
$ProgressPreference = 'SilentlyContinue'
try {
# Bootstrap nuget if we don't have it
if(-not ($NugetPath = (Get-Command 'nuget.exe' -ErrorAction SilentlyContinue).Path)) {
$NugetPath = Join-Path $ENV:USERPROFILE nuget.exe
if(-not (Test-Path $NugetPath)) {
#Invoke-WebRequest -uri 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe' -OutFile $NugetPath
(New-Object System.Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', $NugetPath)
}
}
# Bootstrap PSDepend, re-use nuget.exe for the module
if($path) { $null = mkdir $path -Force }
$NugetParams = 'install', 'PSWindowsUpdate', '-Source', 'https://www.powershellgallery.com/api/v2/',
'-ExcludeVersion', '-NonInteractive', '-OutputDirectory', $Path
& $NugetPath @NugetParams
Remove-Item $NugetPath -Force
}
finally {
$ProgressPreference = $ExistingProgressPreference
}
}
Get-PSWindowsUpdate -Path $env:USERPROFILE
Set-ExecutionPolicy -ExecutionPolicy Bypass -Force
#PSWindows update from https://www.powershellgallery.com/packages/PSWindowsUpdate/1.5.2.2
# The Unblock command crashes the command out
$PSMOdpath = Join-Path $env:USERPROFILE 'PSWindowsUpdate\PSWIndowsUpdate.psm1'
$manifest = Get-Content $psmodpath
$manifest[0] = $null
$manifest | out-file $psmodpath
Import-Module (Join-Path $env:USERPROFILE 'PSWIndowsUpdate') -Force -ErrorAction SilentlyContinue | Out-Null
#Get the install from the windows Update store for any version of windows. NOTE: XP version i do not think is supported
#W8 #Vista #Serv2K8 #W7 Serv2K8R2 W8.1 Serv2K12/R2 W10 W10-1511 Core-Ser2K8 Ser2K8R2 Ser2012 Ser2012R2 Ser2016 #W7 Fix
$KBList = 'KB4013389', 'KB4012598', 'KB4012598', 'KB4012212', 'KB4012212', 'KB4012213', 'KB4012214', 'KB4012606', 'KB4013198', 'KB4012598', 'KB4012212', 'KB4012214', 'KB4012213', 'KB4013429', 'KB4019264'
Get-WUInstall -KBArticleID $KBList -WindowsUpdate -AutoReboot -AcceptAll
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment