-
Notifications
You must be signed in to change notification settings - Fork 239
/
win10-audit-get.ps1
285 lines (251 loc) · 10.5 KB
/
win10-audit-get.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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
param(
[switch]$debug = $false ## if -debug create a log file
)
<# CIAOPS
Script provided as is. Use at own risk. No guarantees or warranty provided.
Description - Report Local Windows 10 machine Audit log settings
Source - https://github.com/directorcia/Office365/blob/master/win10-audit-get.ps1
Prerequisites = 1
1. Ensure aipservice module installed or updated
More scripts available by joining http://www.ciaopspatron.com
#>
## Variables
$systemmessagecolor = "cyan"
$processmessagecolor = "green"
$errormessagecolor = "red"
$warningmessagecolor = "yellow"
## If you have running scripts that don't have a certificate, run this command once to disable that level of security
## set-executionpolicy -executionpolicy bypass -scope currentuser -force
Clear-Host
if ($debug) {
write-host "Script activity logged at ..\win10-audit-get.txt"
start-transcript "..\win10-audit-get.txt" | Out-Null ## Log file created in parent directory that is overwritten on each run
}
write-host -foregroundcolor $systemmessagecolor "Windows 10 Get Audit Log Settings script started`n"
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
If ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
$output = invoke-expression "auditpol /get /category:*"
$value ="Credential Validation"
$outputmatch = ($output -match $value) -replace $value,""
if ($outputmatch.trim() -eq "Success and Failure") {
$displaycolor = $processmessagecolor
}
else {
$displaycolor = $errormessagecolor
}
write-host -foregroundcolor $displaycolor "Account Logon Audit Credential Validation (Device) =",$outputmatch.trim()
$value ="Kerberos Authentication Service"
$outputmatch = ($output -match $value) -replace $value,""
if ($outputmatch.trim() -eq "No Auditing") {
$displaycolor = $processmessagecolor
}
else {
$displaycolor = $errormessagecolor
}
write-host -foregroundcolor $displaycolor "Account Logon Audit Kerberos Authentication Service (Device) =",$outputmatch.trim()
$value ="Account Lockout"
$outputmatch = ($output -match $value) -replace $value,""
if ($outputmatch.trim() -eq "Failure") {
$displaycolor = $processmessagecolor
}
else {
$displaycolor = $errormessagecolor
}
write-host -foregroundcolor $displaycolor "Account Logon Logoff Audit Account Lockout (Device) =",$outputmatch.trim()
$value ="Group Membership"
$outputmatch = ($output -match $value) -replace $value,""
if ($outputmatch.trim() -eq "Success") {
$displaycolor = $processmessagecolor
}
else {
$displaycolor = $errormessagecolor
}
write-host -foregroundcolor $displaycolor "Account Logon Logoff Audit Group Membership (Device) =",$outputmatch.trim()
$value =" Logon"
$outputmatch = ($output -match $value) -replace $value,""
if ($outputmatch.trim() -eq "Success and Failure") {
$displaycolor = $processmessagecolor
}
else {
$displaycolor = $errormessagecolor
}
write-host -foregroundcolor $displaycolor "Account Logon Logoff Audit Logon (Device) =",$outputmatch.trim()
$value ="Other Logon/Logoff Events"
$outputmatch = ($output -match $value) -replace $value,""
if ($outputmatch.trim() -eq "Success and Failure") {
$displaycolor = $processmessagecolor
}
else {
$displaycolor = $errormessagecolor
}
write-host -foregroundcolor $displaycolor "Audit Other Logon Logoff Events (Device) =",$outputmatch.trim()
$value ="Special Logon"
$outputmatch = ($output -match $value) -replace $value,""
if ($outputmatch.trim() -eq "Success") {
$displaycolor = $processmessagecolor
}
else {
$displaycolor = $errormessagecolor
}
write-host -foregroundcolor $displaycolor "Audit Special Logon (Device) =",$outputmatch.trim()
$value ="Security Group Management"
$outputmatch = ($output -match $value) -replace $value,""
if ($outputmatch.trim() -eq "Success") {
$displaycolor = $processmessagecolor
}
else {
$displaycolor = $errormessagecolor
}
write-host -foregroundcolor $displaycolor "Audit Security Group Management (Device) =",$outputmatch.trim()
$value ="User Account Management"
$outputmatch = ($output -match $value) -replace $value,""
if ($outputmatch.trim() -eq "Success and Failure") {
$displaycolor = $processmessagecolor
}
else {
$displaycolor = $errormessagecolor
}
write-host -foregroundcolor $displaycolor "Audit User Account Management (Device) =",$outputmatch.trim()
$value ="Plug and Play Events"
$outputmatch = ($output -match $value) -replace $value,""
if ($outputmatch.trim() -eq "Success") {
$displaycolor = $processmessagecolor
}
else {
$displaycolor = $errormessagecolor
}
write-host -foregroundcolor $displaycolor "Detailed Tracking Audit PNP Activity (Device) =",$outputmatch.trim()
$value ="Process Creation"
$outputmatch = ($output -match $value) -replace $value,""
if ($outputmatch.trim() -eq "Success") {
$displaycolor = $processmessagecolor
}
else {
$displaycolor = $errormessagecolor
}
write-host -foregroundcolor $displaycolor "Detailed Tracking Audit Process Creation (Device) =",$outputmatch.trim()
$value ="Detailed File Share"
$outputmatch = ($output -match $value) -replace $value,""
if ($outputmatch.trim() -eq "Failure") {
$displaycolor = $processmessagecolor
}
else {
$displaycolor = $errormessagecolor
}
write-host -foregroundcolor $displaycolor "Object Access Audit Detailed File Share (Device) =",$outputmatch.trim()
$value =" File Share"
$outputmatch = ($output -match $value) -replace $value,""
if ($outputmatch.trim() -eq "Success and Failure") {
$displaycolor = $processmessagecolor
}
else {
$displaycolor = $errormessagecolor
}
write-host -foregroundcolor $displaycolor "Audit File Share Access (Device) =",$outputmatch.trim()
$value ="Other Object Access Events"
$outputmatch = ($output -match $value) -replace $value,""
if ($outputmatch.trim() -eq "Success and Failure") {
$displaycolor = $processmessagecolor
}
else {
$displaycolor = $errormessagecolor
}
write-host -foregroundcolor $displaycolor "Object Access Audit Other Object Access Events (Device) =",$outputmatch.trim()
$value ="Removable Storage"
$outputmatch = ($output -match $value) -replace $value,""
if ($outputmatch.trim() -eq "Success and Failure") {
$displaycolor = $processmessagecolor
}
else {
$displaycolor = $errormessagecolor
}
write-host -foregroundcolor $displaycolor "Object Access Audit Removable Storage (Device) =",$outputmatch.trim()
$value ="Authentication Policy Change"
$outputmatch = ($output -match $value) -replace $value,""
if ($outputmatch.trim() -eq "Success") {
$displaycolor = $processmessagecolor
}
else {
$displaycolor = $errormessagecolor
}
write-host -foregroundcolor $displaycolor "Audit Authentication Policy Change (Device) =",$outputmatch.trim()
$value ="MPSSVC Rule-Level Policy Change"
$outputmatch = ($output -match $value) -replace $value,""
if ($outputmatch.trim() -eq "Success and Failure") {
$displaycolor = $processmessagecolor
}
else {
$displaycolor = $errormessagecolor
}
write-host -foregroundcolor $displaycolor "Policy Change Audit MPSSVC Rule Level Policy Change (Device) =",$outputmatch.trim()
$value ="Other Policy Change Events"
$outputmatch = ($output -match $value) -replace $value,""
if ($outputmatch.trim() -eq "Failure") {
$displaycolor = $processmessagecolor
}
else {
$displaycolor = $errormessagecolor
}
write-host -foregroundcolor $displaycolor "Policy Change Audit Other Policy Change Events (Device) =",$outputmatch.trim()
$value ="Audit Policy Change"
$outputmatch = ($output -match $value) -replace $value,""
if ($outputmatch.trim() -eq "Success") {
$displaycolor = $processmessagecolor
}
else {
$displaycolor = $errormessagecolor
}
write-host -foregroundcolor $displaycolor "Audit Changes to Audit Policy (Device) =",$outputmatch.trim()
$value =" Sensitive Privilege Use"
$outputmatch = ($output -match $value) -replace $value,""
if ($outputmatch.trim() -eq "Success and Failure") {
$displaycolor = $processmessagecolor
}
else {
$displaycolor = $errormessagecolor
}
write-host -foregroundcolor $displaycolor "Privilege Use Audit Sensitive Privilege Use (Device) =",$outputmatch.trim()
$value ="Other System Events"
$outputmatch = ($output -match $value) -replace $value,""
if ($outputmatch.trim() -eq "Success and Failure") {
$displaycolor = $processmessagecolor
}
else {
$displaycolor = $errormessagecolor
}
write-host -foregroundcolor $displaycolor "System Audit Other System Events (Device) =",$outputmatch.trim()
$value ="Security State Change"
$outputmatch = ($output -match $value) -replace $value,""
if ($outputmatch.trim() -eq "Success") {
$displaycolor = $processmessagecolor
}
else {
$displaycolor = $errormessagecolor
}
write-host -foregroundcolor $displaycolor "System Audit Security State Change (Device) =",$outputmatch.trim()
$value ="Security System Extension"
$outputmatch = ($output -match $value) -replace $value,""
if ($outputmatch.trim() -eq "Success") {
$displaycolor = $processmessagecolor
}
else {
$displaycolor = $errormessagecolor
}
write-host -foregroundcolor $displaycolor "Audit Security System Extension (Device) =",$outputmatch.trim()
$value ="System Integrity"
$outputmatch = ($output -match $value) -replace $value,""
if ($outputmatch.trim() -eq "Success and Failure") {
$displaycolor = $processmessagecolor
}
else {
$displaycolor = $errormessagecolor
}
write-host -foregroundcolor $displaycolor "System Audit System Integrity (Device) =",$outputmatch.trim()
}
else {
write-host -foregroundcolor $warningmessagecolor "Audit Policy results only available when script run as Administrator`n"
}
write-host -foregroundcolor $systemmessagecolor "`nWindows 10 Get Audit Log Settings script finished"
if ($debug) {
Stop-Transcript | Out-Null
}