-
Notifications
You must be signed in to change notification settings - Fork 2
/
Start-GCWindowsUpdate.ps1
44 lines (34 loc) · 1.24 KB
/
Start-GCWindowsUpdate.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<#
.SYNOPSIS
Starts the Windwos Update service (wuauserv) and downloads all available updates.
.DESCRIPTION
Due to the latest versions of Microsoft Windows being rather forward about applying
updates and rebooting machines, this function allows you to install the updates on your own schedule.
Start-GCWindowsUpdate performs the following tasks:
- Sets the Windows Update service, named wuauserv, to a StartupType of Automatic
- Starts the Windows Update service
- Downloads and installs all required Windows updates
Rebooting after the updates is not forced.
.EXAMPLE
The following example installs all required updates on the local machine:
> Start-GCWindowsUpdate
#>
function Start-GCWindowsUpdate {
[CmdletBinding()]
[Alias()]
[OutputType([String])]
Param()
"Start-GCWindowsUpdate initiated"
Import-Module -Name GCTest
if (Test-GCAdminShell -ShowError) {
"Importing the PSWindowsUpdate module"
Import-Module -Name PSWindowsUpdate
$wu = Get-Service -Name wuauserv
"Starting the Windows Update service"
Set-Service -StartupType Automatic -InputObject $wu
Start-Service -InputObject $wu
"Installing Windows Updates"
Get-WUInstall -AcceptAll
}
"Start-GCWindowsUpdate completed"
}