Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into my
  • Loading branch information
basictheprogram committed Feb 2, 2020
2 parents ca0334a + 5d8630e commit 1864e01
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
42 changes: 42 additions & 0 deletions scripts/install-cumulative-update.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
$ErrorActionPreference = 'Stop'

$Session = New-Object -ComObject 'Microsoft.Update.Session'
$Session.ClientApplicationID = 'Packer Windows Update Installer'
$UpdateSearcher = $Session.CreateUpdateSearcher()
Write-Output "Searching for Windows updates ..."
$SearchResult = $UpdateSearcher.Search("IsInstalled=0 and Type='Software' and IsHidden=0")
$Updates = $SearchResult.Updates
$UpdatesToDownload = New-Object -ComObject 'Microsoft.Update.UpdateColl'

if ($Updates.Count -gt 0) {
$i = $Updates.Count - 1
while ($i -ge 0) {
$Update = $Updates.Item($i)
if ($Update.Title -match "Cumulative Update") {
Write-Output "Found $($Update.Title)"
if (!($Update.EulaAccepted)) {
$Update.AcceptEula()
}
$UpdatesToDownload.Add($Update) | Out-Null
break
}
$i--
}
}

if ($UpdatesToDownload.Count -eq 0) {
Write-Output "No cumulative Windows updates found."
} else {
Write-Output "Downloading cumulative Windows update ..."
$Downloader = $Session.CreateUpdateDownloader()
$Downloader.Updates = $UpdatesToDownload
$Downloader.Download()

Write-Output "Installing Windows update ..."
$Installer = $Session.CreateUpdateInstaller()
$Installer.Updates = $UpdatesToDownload
$InstallationResult = $Installer.Install()

Write-Output "Installation Result: $($InstallationResult.ResultCode)"
Write-Output "Reboot Required: $($InstallationResult.RebootRequired)"
}
4 changes: 2 additions & 2 deletions scripts/vm-guest-tools.bat
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if exist "C:\Users\vagrant\windows.iso" (
)

if not exist "C:\Windows\Temp\windows.iso" (
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://softwareupdate.vmware.com/cds/vmw-desktop/ws/15.5.0/14665864/windows/packages/tools-windows.tar', 'C:\Windows\Temp\vmware-tools.tar')" <NUL
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://softwareupdate.vmware.com/cds/vmw-desktop/ws/15.5.1/15018445/windows/packages/tools-windows.tar', 'C:\Windows\Temp\vmware-tools.tar')" <NUL
cmd /c ""C:\Program Files\7-Zip\7z.exe" x C:\Windows\Temp\vmware-tools.tar -oC:\Windows\Temp"
FOR /r "C:\Windows\Temp" %%a in (VMware-tools-windows-*.iso) DO REN "%%~a" "windows.iso"
rd /S /Q "C:\Program Files (x86)\VMWare"
Expand All @@ -40,7 +40,7 @@ if exist "C:\Users\vagrant\VBoxGuestAdditions.iso" (
)

if not exist "C:\Windows\Temp\VBoxGuestAdditions.iso" (
powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (New-Object System.Net.WebClient).DownloadFile('https://download.virtualbox.org/virtualbox/6.0.10/VBoxGuestAdditions_6.0.10.iso', 'C:\Windows\Temp\VBoxGuestAdditions.iso')" <NUL
powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (New-Object System.Net.WebClient).DownloadFile('https://download.virtualbox.org/virtualbox/6.1.2/VBoxGuestAdditions_6.1.2.iso', 'C:\Windows\Temp\VBoxGuestAdditions.iso')" <NUL
)

cmd /c ""C:\Program Files\7-Zip\7z.exe" x C:\Windows\Temp\VBoxGuestAdditions.iso -oC:\Windows\Temp\virtualbox"
Expand Down

0 comments on commit 1864e01

Please sign in to comment.