Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Bob Tanner
packer-windows
Commits
70d02ff1
Unverified
Commit
70d02ff1
authored
Oct 22, 2017
by
Stefan Scherer
Browse files
Skip Win10 update on WinServer 1709
parent
6d2984d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/win-updates.ps1
View file @
70d02ff1
...
...
@@ -13,6 +13,14 @@ 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"
...
...
@@ -69,15 +77,19 @@ 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
)
{
...
...
@@ -144,7 +156,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
)
{
if
(
$InstallationResult
.
RebootRequired
-Or
$InstallationResult
.
ResultCode
-Eq
4
)
{
$
global
:
RestartRequired
=
1
}
else
{
$
global
:
RestartRequired
=
0
...
...
Write
Preview
Supports
Markdown
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