-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGet-WindowsUpdateSetting.ps1
More file actions
69 lines (64 loc) · 2.06 KB
/
Copy pathGet-WindowsUpdateSetting.ps1
File metadata and controls
69 lines (64 loc) · 2.06 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<#
.Synopsis
Outputs the Windows Update setting on a computer.
.DESCRIPTION
Takes a string array of computer names and outputs
the computer's Windows Update setting.
.EXAMPLE
Get-WindowsUpdateSetting $ComputerNames
.EXAMPLE
$ComputerNames | Get-WindowsUpdateSetting
#>
Function Get-WindowsUpdateSetting
{
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[string[]]$ComputerNames
)
Process
{
Foreach ($ComputerName in $ComputerNames)
{
Try
{
$Registry = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $ComputerName)
$RegistryKey= $Registry.OpenSubKey('SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate\\Auto Update')
$AUOptions = $RegistryKey.GetValue('AUOptions')
If ($AUOptions -eq '1')
{
$UpdateSetting = 'Never check for updates (not recommended)'
}
ElseIf ($AUOptions -eq '2')
{
$UpdateSetting = 'Check for updates but let me choose whether to download and install them'
}
ElseIf ($AUOptions -eq '3')
{
$UpdateSetting = 'Download updates but let me choose whether to install them'
}
ElseIf ($AUOptions -eq '4')
{
$UpdateSetting = 'Install updates automatically (recommended)'
}
Else
{
$UpdateSetting = "Unknown Windows Update setting"
}
}
Catch
{
$UpdateSetting = "Unable to connect to system's registry"
}
[psobject]$System = @{
'Name' = $ComputerName;
'UpdateSetting' = $UpdateSetting
}
$System
}
}
}