joefitzgerald / packer-windows

Windows Packer Templates
MIT License
1.63k stars 1.12k forks source link

Windows 7 SP1 - KB3102810 #203

Open bdwyertech opened 8 years ago

bdwyertech commented 8 years ago

FYI, the KB3102810 is not being installed properly at the moment. I think it might be better integrated into the win-updates.ps1 script... That's what I've done for now at least. You can't actually install the hotfix until SP1 is installed, therefore if you are using the default Win7 Enterprise image as set in this repo, that hotfix never gets installed.

It was initially added with https://github.com/joefitzgerald/packer-windows/commit/53fda6e9a157eb279a1d9557cba70093595f1778

I think this might be better added to the Windows Update PowerShell script, as a function with some guard clauses.

function Fix-Win7SP1 {
    if ((Get-WmiObject -Class Win32_OperatingSystem).Version -eq '6.1.7601') {
        if ([System.IntPtr]::Size -eq 4) { $osarch='x86' } else { $osarch='x64' }
        $SP1HotFixUrl = "https://download.microsoft.com/download/A/0/9/A09BC0FD-747C-4B97-8371-1A7F5AC417E9/Windows6.1-KB3102810-${osarch}.msu"
        $SP1HotFix = "C:\Windows\Temp\$($SP1HotFixURL.Substring($SP1HotFixURL.LastIndexOf('/') + 1))"

        # Download & Install Latest Windows Update Client
        If (!(Get-HotFix -Id 'KB3102810' -ErrorAction SilentlyContinue))
        {
            Write-Host "Downloading Win7-SP1 WU Client Update (KB3102810)"
            (new-object net.webclient).DownloadFile($SP1HotFixURL, $SP1HotFix)
            Write-Host "Installing Win7-SP1 WU Client Update (KB3102810)"
            Start-Process -FilePath wusa -ArgumentList $SP1HotFix, /quiet -Wait
            Write-Host 'This update requires a reboot'
        }
    }
}