-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaudit.ps1
209 lines (200 loc) · 10.5 KB
/
audit.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
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#Cyber Essentials in one script ;)
#Check Password Policy
net accounts
#get local account info
net user administrator
net user guest
#Check if Defender is enabled
Get-MpComputerStatus
Get-MpPreference
$ATPEnabled = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows Advanced Threat Protection\Status" -Name "OnBoardingState"
if($ATPEnabled.OnboardingState -eq 1){Write-Host "Defender for Endpoint Enabled (ATP)" -ForegroundColor Green}else{Write-Host "Defender for Endpoint Disabled (ATP)" -ForegroundColor Red}
#check for FDE (not in cyber E but yolo)
Get-BitLockerVolume
#Check firewall is anbled
Get-NetFirewallProfile
#CHeck Windows Update Status
Get-Service -Name wuauserv
#From the scripting guy (microsoft)
Function Get-WUSettings {
[cmdletbinding()]
Param(
[switch]$viaRegistry=$false
)
Begin {
# Get the Operating system
$OSVersion = [environment]::OSVersion.Version
# Initialize object
$WshShell = New-Object -ComObject Wscript.Shell
$polkey = 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU'
$stdkey = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update'
}
Process {
if ($viaRegistry) {
try {
$AUEnabled = $WshShell.RegRead("$polkey\NoAutoUpdate")
} catch {
# if this value is absent, it means it's turned on
$AUEnabled = 0
}
Switch ($AUEnabled) {
1 {$AUEnabled = $false}
0 {$AUEnabled = $true }
}
try {
$AUOptions = $WshShell.RegRead("$polkey\AUOptions")
} catch {
try {
$AUOptions = $WshShell.RegRead("$stdkey\AUOptions")
} catch {
$AUOptions = 0
}
}
Switch ($AUOptions) {
0 {$AUNotificationLevel = 'Not Configured'}
1 {$AUNotificationLevel = 'Never check for updates'}
2 {$AUNotificationLevel = 'Notify Before Download'}
3 {$AUNotificationLevel = 'Notify Before Installation'}
4 {$AUNotificationLevel = 'Install updates automatically'}
}
try {
$IncludeRecommendedUpdates = $WshShell.RegRead("$polkey\IncludeRecommendedUpdates")
} catch {
# if the value is absent we get it from
$IncludeRecommendedUpdates = $WshShell.RegRead("$stdkey\IncludeRecommendedUpdates")
}
Switch ($IncludeRecommendedUpdates) {
0 {$GetRecommendedUpdates = $false}
1 {$GetRecommendedUpdates = $true}
}
try {
$UseWUServerVal = $WshShell.RegRead("$polkey\UseWUServer")
} catch {
# if the value doesn't exist, it means that we don't use a WSUS server
$UseWUServerVal = 0
}
Switch ($UseWUServerVal) {
1 {$UseWUServer = $true}
0 {$UseWUServer = $false }
}
# Create a default object with a subset of properties
$obj = New-Object -TypeName psobject -Property @{
'Is Automatic Update Enabled' = $AUEnabled
'Use a WSUS Server' = $UseWUServer
'Automatic Updates Notification' = $AUNotificationLevel;
'Receive recommended udpates' = $GetRecommendedUpdates;
}
if ($OSVersion -lt [version]'6.2') {
try {
$ScheduledInstallDay = $WshShell.RegRead("$polkey\ScheduledInstallDay")
$ScheduledInstallTime = $WshShell.RegRead("$polkey\ScheduledInstallTime")
} catch {
try {
$ScheduledInstallDay = $WshShell.RegRead("$stdkey\ScheduledInstallDay")
$ScheduledInstallTime = $WshShell.RegRead("$stdkey\ScheduledInstallTime")
} catch {
# Absent = Every Day @3 AM but I prefer to leave it blank in the returned object
}
}
Switch ($ScheduledInstallDay) {
0 {$InstallDay = 'Every Day'}
1 {$InstallDay = 'Every Sunday'}
2 {$InstallDay = 'Every Monday'}
3 {$InstallDay = 'Every Tuesday'}
4 {$InstallDay = 'Every Wednesday'}
5 {$InstallDay = 'Every Thursday'}
6 {$InstallDay = 'Every Friday'}
7 {$InstallDay = 'Every Saturday'}
}
if ($ScheduledInstallTime) {
$InstallTime = New-TimeSpan -Hours $ScheduledInstallTime
}
$obj | Add-Member -MemberType NoteProperty -Name 'Install Frequency' -Value $InstallDay
$obj | Add-Member -MemberType NoteProperty -Name 'Install Time' -Value $InstallTime
} else {
# These properties don't exist anymore on Windows 8
}
# Add extra properties
if ($UseWUServer) {
try {
$WUServer = $WshShell.RegRead('HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\WUServer')
$WUStatusServer = $WshShell.RegRead('HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\WUStatusServer')
} catch {
# we silently fail
}
$obj | Add-Member -MemberType NoteProperty -Name 'WSUS Server' -Value $WUServer
$obj | Add-Member -MemberType NoteProperty -Name 'WSUS Status URL' -Value $WUStatusServer
}
try {
$OptinGUID = $WshShell.RegRead('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Services\DefaultService')
} catch {
# Fail silently
}
if ($OptinGUID -eq '7971f918-a847-4430-9279-4a52d1efe18d') {
$obj | Add-Member -MemberType NoteProperty -Name "Opted-in Microsoft Update" -Value $true
} else {
$obj | Add-Member -MemberType NoteProperty -Name "Opted-in Microsoft Update" -Value $false
}
# Return our object
$obj
} else {
# We use Com Object
$COMWUSettings = (New-Object -ComObject Microsoft.Update.AutoUpdate).Settings
# Settings might be controlled by GPO
if ($COMWUSettings.ReadOnly) {
# Use the registry
Get-WUSettings -viaRegistry:$true
break
} else {
$UseWUServer = $false
}
Switch ($COMWUSettings.NotificationLevel) {
0 {$AUNotificationLevel = 'Not Configured'}
1 {$AUNotificationLevel = 'Never check for updates'}
2 {$AUNotificationLevel = 'Notify Before Download'}
3 {$AUNotificationLevel = 'Notify Before Installation'}
4 {$AUNotificationLevel = 'Install updates automatically'}
}
$isAUenabled = (New-Object -ComObject Microsoft.Update.AutoUpdate).serviceEnabled
$obj = New-Object -TypeName psobject -Property @{
'Is Automatic Update Enabled' = $isAUenabled
'Automatic Updates Notification' = $AUNotificationLevel;
'Use a WSUS Server' = $UseWUServer
'Receive recommended udpates' = $COMWUSettings.IncludeRecommendedUpdates;
}
if ($OSVersion -lt [version]'6.2') {
Switch ($COMWUSettings.ScheduledInstallationDay) {
0 {$InstallDay = 'Every Day'}
1 {$InstallDay = 'Every Sunday'}
2 {$InstallDay = 'Every Monday'}
3 {$InstallDay = 'Every Tuesday'}
4 {$InstallDay = 'Every Wednesday'}
5 {$InstallDay = 'Every Thursday'}
6 {$InstallDay = 'Every Friday'}
7 {$InstallDay = 'Every Saturday'}
}
if ($COMWUSettings.ScheduledInstallationTime) {
$InstallTime = New-TimeSpan -Hours $COMWUSettings.ScheduledInstallationTime
}
$obj | Add-Member -MemberType NoteProperty -Name 'Install Frequency' -Value $InstallDay
$obj | Add-Member -MemberType NoteProperty -Name 'Install Time' -Value $InstallTime
} else {
# not available on W8
}
(New-Object -ComObject Microsoft.Update.ServiceManager).services | ForEach-Object {
if ($_.IsDefaultAUService) {
$OptinGUID = $_.ServiceID
}
}
if ($OptinGUID -eq '7971f918-a847-4430-9279-4a52d1efe18d') {
$obj | Add-Member -MemberType NoteProperty -Name "Opted-in Microsoft Update" -Value $true
} else {
$obj | Add-Member -MemberType NoteProperty -Name "Opted-in Microsoft Update" -Value $false
}
# return
$obj
}
}
End {}
}
Get-WUSettings