vagrant-windows-update 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/vagrant-windows-update/version.rb +1 -1
- data/lib/vagrant-windows-update/windows-update.ps1 +32 -36
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 63e248d30d6a3fc4f3ba91cf9170c96d7ac45ae6
|
|
4
|
+
data.tar.gz: 5d7a309419c7a4b8065de1eda991c10303b26192
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 51292d0b6e50429280cfb57397fd93ba719e7440a069ee5c936ac617354d958785f13ea18cd8aa0b830037acf7bcfc7e91926e52ee13ecb0bc019109242a1632
|
|
7
|
+
data.tar.gz: acf3aef2ef012f164abb9c8bddf2d374b4a1270d844a46722457079ce5719571c2642a09e08ecc0645c63ae7b529015263a126a73a25d16b24f8650203ddba83
|
|
@@ -94,52 +94,48 @@ $updateSession = New-Object -ComObject 'Microsoft.Update.Session'
|
|
|
94
94
|
$updateSession.ClientApplicationID = 'vagrant-windows-update'
|
|
95
95
|
|
|
96
96
|
Write-Output 'Searching for Windows updates...'
|
|
97
|
-
$updateSearcher = $updateSession.CreateUpdateSearcher()
|
|
98
97
|
$updatesToDownload = New-Object -ComObject 'Microsoft.Update.UpdateColl'
|
|
98
|
+
$updatesToInstall = New-Object -ComObject 'Microsoft.Update.UpdateColl'
|
|
99
|
+
$updateSearcher = $updateSession.CreateUpdateSearcher()
|
|
99
100
|
$searchResult = $updateSearcher.Search("IsInstalled=0 and Type='Software' and IsHidden=0")
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
$update = $searchResult.Updates.Item($i)
|
|
101
|
+
for ($i = 0; $i -lt $searchResult.Updates.Count; ++$i) {
|
|
102
|
+
$update = $searchResult.Updates.Item($i)
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
if ($update.InstallationBehavior.CanRequestUserInput) {
|
|
105
|
+
continue
|
|
106
|
+
}
|
|
107
107
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
if (!$update.AutoSelectOnWebSites) {
|
|
109
|
+
continue
|
|
110
|
+
}
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
$updateDate = $update.LastDeploymentChangeTime.ToString('yyyy-MM-dd')
|
|
113
|
+
$updateSize = ($update.MaxDownloadSize/1024/1024).ToString('0.##')
|
|
114
|
+
Write-Output "Found Windows update ($updateDate; $updateSize MB): $($update.Title)"
|
|
113
115
|
|
|
114
|
-
|
|
115
|
-
continue
|
|
116
|
-
}
|
|
116
|
+
$update.AcceptEula() | Out-Null
|
|
117
117
|
|
|
118
|
+
if (!$update.IsDownloaded) {
|
|
118
119
|
$updatesToDownload.Add($update) | Out-Null
|
|
119
120
|
}
|
|
120
121
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
$updateDownloader = $updateSession.CreateUpdateDownloader()
|
|
124
|
-
$updateDownloader.Updates = $updatesToDownload
|
|
125
|
-
$updateDownloader.Download() | Out-Null
|
|
126
|
-
}
|
|
122
|
+
$updatesToInstall.Add($update) | Out-Null
|
|
123
|
+
}
|
|
127
124
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
125
|
+
if ($updatesToDownload.Count) {
|
|
126
|
+
Write-Output 'Downloading Windows updates...'
|
|
127
|
+
$updateDownloader = $updateSession.CreateUpdateDownloader()
|
|
128
|
+
$updateDownloader.Updates = $updatesToDownload
|
|
129
|
+
$updateDownloader.Download() | Out-Null
|
|
130
|
+
}
|
|
135
131
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
} else {
|
|
144
|
-
Write-Output 'No Windows updates found'
|
|
132
|
+
if ($updatesToInstall.Count) {
|
|
133
|
+
Write-Output 'Installing Windows updates...'
|
|
134
|
+
$updateInstaller = $updateSession.CreateUpdateInstaller()
|
|
135
|
+
$updateInstaller.Updates = $updatesToInstall
|
|
136
|
+
$installResult = $updateInstaller.Install()
|
|
137
|
+
ExitWhenRebootRequired $true
|
|
138
|
+
Exit 0
|
|
145
139
|
}
|
|
140
|
+
|
|
141
|
+
Write-Output 'No Windows updates found'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vagrant-windows-update
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rui Lopes
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-
|
|
11
|
+
date: 2017-07-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|