Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Bob Tanner
packer-windows
Commits
0d8199d2
Unverified
Commit
0d8199d2
authored
Oct 25, 2017
by
Stefan Scherer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert 1709 changes
parent
6e62f3b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
19 deletions
+7
-19
scripts/win-updates.ps1
scripts/win-updates.ps1
+7
-19
No files found.
scripts/win-updates.ps1
View file @
0d8199d2
...
...
@@ -13,14 +13,6 @@ function LogWrite {
Write-Host
$logstring
}
function
IsServer
{
$caption
=
(
Get-WmiObject
-class
Win32_OperatingSystem
-computername
"."
)
.
Caption
if
(
$caption
-Like
"*Windows Server*"
)
{
return
$true
}
return
$false
}
function
Check-ContinueRestartOrEnd
()
{
$RegistryKey
=
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
$RegistryEntry
=
"InstallWindowsUpdates"
...
...
@@ -77,19 +69,15 @@ function Install-WindowsUpdates() {
if
(
$Update
.
InstallationBehavior
.
CanRequestUserInput
)
{
LogWrite
"> Skipping:
$(
$Update
.
Title
)
because it requires user input"
}
else
{
if
(
IsServer
-And
(
$
(
$Update
.
Title
)
-Like
'*Windows 10*'
))
{
LogWrite
"> Skipping:
$(
$Update
.
Title
)
because it is for Windows 10 and we run on Windows Server"
}
else
{
if
(
!
(
$Update
.
EulaAccepted
))
{
LogWrite
"> Note:
$(
$Update
.
Title
)
has a license agreement that must be accepted. Accepting the license."
$Update
.
AcceptEula
()
[
bool
]
$addThisUpdate
=
$true
$
script
:
CycleUpdateCount
++
LogWrite
"> Note:
$(
$Update
.
Title
)
has a license agreement that must be accepted. Accepting the license."
$Update
.
AcceptEula
()
[
bool
]
$addThisUpdate
=
$true
$
script
:
CycleUpdateCount
++
}
else
{
[
bool
]
$addThisUpdate
=
$true
$
script
:
CycleUpdateCount
++
[
bool
]
$addThisUpdate
=
$true
$
script
:
CycleUpdateCount
++
}
}
}
if
([
bool
]
$addThisUpdate
)
{
...
...
@@ -156,7 +144,7 @@ function Install-WindowsUpdates() {
LogWrite
"Installation Result:
$(
$InstallationResult
.
ResultCode
)
"
LogWrite
"Reboot Required:
$(
$InstallationResult
.
RebootRequired
)
"
LogWrite
'Listing of updates installed and individual installation results:'
if
(
$InstallationResult
.
RebootRequired
-Or
$InstallationResult
.
ResultCode
-Eq
4
)
{
if
(
$InstallationResult
.
RebootRequired
)
{
$
global
:
RestartRequired
=
1
}
else
{
$
global
:
RestartRequired
=
0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment