-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetadfslogscript.ps1
739 lines (505 loc) · 28.6 KB
/
getadfslogscript.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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
############################################################
#AD FS/WAP 情報採取スクリプト
#LastUpdate:2020/02/17
#
###採取情報###
#ADFS/WAP 構成情報
#ADFS Admin イベント ログ
#WAP Admin イベント ログ <- 2020/1/1 追加
#application/system/security イベント ログ
#Certutil 出力結果
#ipconfig /all
#netsh http show ssl 出力結果
#Get-HotFix
##2020/2/17 追加
#WIASupportedUserAgents の一覧
#netstat -anot
#netsh http show urlacl
#tasklist /svc
#W2k19 で追加された AD FS コマンド
## 2021/11/24 追加
#http.err log
############################################################
######初期チェック。 OS バージョンと ProductType の確認処理
Function startup(){
###OS バージョンチェック
#6.3 未満 = NG
#6.4 未満 = W2k12R2
#6.4 以上かつ BuildNumber が 17763 未満 = W2k16
#それ以外 = W2k19 以上
##OS バージョン取得
$oschk = ""
$tmpOSVersion = Get-WmiObject Win32_OperatingSystem
$tmpOSBuildNumber = $tmpOSVersion.BuildNumber
$ProductType = (Get-WmiObject Win32_OperatingSystem).ProductType
$tmpOSVersion = $tmpOSVersion.Version
$tmpVersion = $tmpOSVersion.Replace( ".$tmpOSBuildNumber", "" )
##数値化
$WinVer = [decimal]$tmpVersion
##判定処理
# Windows Server 2012 R2/Windows 8.1 以降のいずれかでなければ false を返す。
# 20200217 : Windows Server 2016/2019 の判定条件を追加
if($WinVer -lt "6.3"){
$oschk = "false"
}elseif($WinVer -lt "6.4"){
$oschk = "W2k12R2"
}elseif($WinVer -eq "10.0" -and $tmpOSBuildNumber -lt "17763"){
$oschk = "W2k16"
}else{
$oschk = "W2k19"
}
##OS バージョン、 ProductType を返す。
return $oschk,$ProductType
}
######情報採取停止処理
Function GetLog ($oschk,$ProductType) {
###保存先フォルダー作成
$str_path = (Convert-Path .)
$FolderName = $str_path + "\" + $(Get-Date).ToString("yyyyMMdd") + "_" + $(Get-Date).ToString("HHmm") + "_" + $Env:COMPUTERNAME
##フォルダー作成
#フォルダー作成に失敗した場合は Catch に移動し処理を停止する。
try{
$Item = New-Item -Path $FolderName -ItemType directory
$FolderName = $Item.FullName
}catch{
$ErrorMessage = $_.Exception_Message
$ErrorMessage
Write-Host "There is an error : $error" -ForegroundColor Yellow
exit
}
##フォルダー パスの確認
#フォルダーが確認できなかった失敗した場合は処理を停止する
$PathChk = Test-Path $FolderName
if($PathChk -eq "True"){
Write-Host "Created folder "$FolderName
}else{
Write-Host "It is not a valided path."
exit
}
###ProductType が 1 (Client) 以外の場合役割の確認を行う。
if($ProductType -ne "1"){
###AD FS の役割の有無のチェック
$ADFSCheck = (Get-WindowsFeature -Name ADFS-Federation).InstallState
if ($ADFSCheck -eq "Installed"){
$ADFSCheck = "true"
}else{
$ADFSCheck = "false"
}
#WAP の役割の有無のチェック
$WAPCheck = (Get-WindowsFeature -Name Web-Application-Proxy).InstallState
if ($WAPCheck -eq "Installed"){
$WAPCheck = "true"
}else{
$WAPCheck = "false"
}
}
###セキュリティ・アプリケーション・システム・ CAPI2 ログを evtx 形式で取得
Write-Host "Gathering event logs..."
$tmpsystem = $FolderName + "\System.evtx"
wevtutil epl system $tmpsystem
$tmpapp = $FolderName + "\Application.evtx"
wevtutil epl Application $tmpapp
$tmpsec = $FolderName + "\security.evtx"
wevtutil epl security $tmpsec
$tmpcapi2 = $FolderName + "\capi2.evtx"
wevtutil epl "Microsoft-Windows-CAPI2/Operational" $tmpcapi2
###ipconfig の結果を txt 形式で取得
$tmpip = $FolderName + "\ipconfig.txt"
ipconfig /all > $tmpip
##Hotfix 取得
$hotfix = $FolderName + "\GetHotFix.txt"
Get-HotFix | fl | Out-File $hotfix
$netstat_anot = $FolderName + "\netstat_anot.txt"
netstat -anot > $netstat_anot
$netsh_urlacl = $FolderName + "\netsh_urlacl.txt"
netsh http show urlacl > $netsh_urlacl
$tasklist_svc = $FolderName + "\tasklist_svc.txt"
tasklist /svc > $tasklist_svc
Write-Host "Completed gathering event logs."
### OS バージョンごとに AD FS Admin ログと各種 Get コマンドの結果を取得
if ($oschk -eq "W2k12R2"){
## AD FS 3.0
if($ADFSCheck -eq "true"){
Write-Host "Gathering AD FS Config..."
$adfslog = $FolderName + "\ADFSAdmin.evtx"
wevtutil epl "AD FS/Admin" $adfslog
$adfslog = $FolderName + "\ADFSDebug.evtx"
wevtutil epl "AD FS Tracing/Debug" $adfslog
$adfslog = $FolderName + "\Get-AdfsAdditionalAuthenticationRule.txt"
Get-AdfsAdditionalAuthenticationRule | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsAttributeStore.txt"
Get-AdfsAttributeStore | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsAuthenticationProvider.txt"
Get-AdfsAuthenticationProvider | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsAuthenticationProviderWebContent.txt"
Get-AdfsAuthenticationProviderWebContent | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsCertificate.txt"
Get-AdfsCertificate | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsClaimDescription.txt"
Get-AdfsClaimDescription | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsClaimsProviderTrust.txt"
Get-AdfsClaimsProviderTrust | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsClient.txt"
Get-AdfsClient | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsDeviceRegistration.txt"
Get-AdfsDeviceRegistration | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsDeviceRegistrationUpnSuffix.txt"
Get-AdfsDeviceRegistrationUpnSuffix | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsEndpoint.txt"
Get-AdfsEndpoint | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsGlobalAuthenticationPolicy.txt"
Get-AdfsGlobalAuthenticationPolicy | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsGlobalWebContent.txt"
Get-AdfsGlobalWebContent | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsNonClaimsAwareRelyingPartyTrust.txt"
Get-AdfsNonClaimsAwareRelyingPartyTrust | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsProperties.txt"
Get-AdfsProperties | fl | Out-File $adfslog
Write-Output "======== WIASupportedUserAgents ========" | Out-File $adfslog -Append
Get-AdfsProperties |select -ExpandProperty WIASupportedUserAgents | Out-File $adfslog -Append
Get-AdfsProperties |select -ExpandProperty WIASupportedUserAgents | Out-File $adfslog -Append
$adfslog = $FolderName + "\Get-AdfsRegistrationHosts.txt"
Get-AdfsRegistrationHosts | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsRelyingPartyTrust.txt"
Get-AdfsRelyingPartyTrust | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsRelyingPartyWebContent.txt"
Get-AdfsRelyingPartyWebContent | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsSslCertificate.txt"
Get-AdfsSslCertificate | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsSyncProperties.txt"
Get-AdfsSyncProperties | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsWebApplicationProxyRelyingPartyTrust.txt"
Get-AdfsWebApplicationProxyRelyingPartyTrust | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsWebConfig.txt"
Get-AdfsWebConfig | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsWebTheme.txt"
Get-AdfsWebTheme | fl | Out-File $adfslog
$adfslog = $FolderName + "\netsh_ssl.txt"
netsh http show ssl | Out-File $adfslog
Write-Host "Completed gathering AD FS Config."
}
## WAP 3.0
if($WAPCheck -eq "true"){
Write-Host "Gathering WAP Config..."
$adfslog = $FolderName + "\ADFSAdmin.evtx"
wevtutil epl "AD FS/Admin" $adfslog
$adfslog = $FolderName + "\ADFSDebug.evtx"
wevtutil epl "AD FS Tracing/Debug" $adfslog
$adfslog = $FolderName + "\WAPAdmin.evtx"
wevtutil epl "Microsoft-Windows-WebApplicationProxy/Admin" $adfslog
$adfslog = $FolderName + "\Get-WebApplicationProxyApplication.txt"
Get-WebApplicationProxyApplication | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-WebApplicationProxyAvailableADFSRelyingParty.txt"
Get-WebApplicationProxyAvailableADFSRelyingParty | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-WebApplicationProxyConfiguration.txt"
Get-WebApplicationProxyConfiguration | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-WebApplicationProxyHealth.txt"
Get-WebApplicationProxyHealth | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-WebApplicationProxySslCertificate.txt"
Get-WebApplicationProxySslCertificate | fl | Out-File $adfslog
$adfslog = $FolderName + "\netsh_ssl.txt"
netsh http show ssl > $adfslog
Write-Host "Completed gathering WAP Config."
}
}
if ($oschk -eq "W2k16"){
## AD FS 4.0
if($ADFSCheck -eq "true"){
Write-Host "Gathering AD FS Config..."
$adfslog = $FolderName + "\ADFSAdmin.evtx"
wevtutil epl "AD FS/Admin" $adfslog
$adfslog = $FolderName + "\ADFSDebug.evtx"
wevtutil epl "AD FS Tracing/Debug" $adfslog
$adfslog = $FolderName + "\Get-AdfsAccessControlPolicy.txt"
Get-AdfsAccessControlPolicy | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsAdditionalAuthenticationRule.txt"
Get-AdfsAdditionalAuthenticationRule | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsApplicationGroup.txt"
Get-AdfsApplicationGroup | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsApplicationPermission.txt"
Get-AdfsApplicationPermission | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsAttributeStore.txt"
Get-AdfsAttributeStore | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsAuthenticationProvider.txt"
Get-AdfsAuthenticationProvider | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsAuthenticationProviderWebContent.txt"
Get-AdfsAuthenticationProviderWebContent | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsAzureMfaConfigured.txt"
Get-AdfsAzureMfaConfigured | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsCertificate.txt"
Get-AdfsCertificate | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsCertificateAuthority.txt"
Get-AdfsCertificateAuthority | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsClaimDescription.txt"
Get-AdfsClaimDescription | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsClaimsProviderTrust.txt"
Get-AdfsClaimsProviderTrust | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsClaimsProviderTrustsGroup.txt"
Get-AdfsClaimsProviderTrustsGroup | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsClient.txt"
Get-AdfsClient | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsDeviceRegistration.txt"
Get-AdfsDeviceRegistration | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsDeviceRegistrationUpnSuffix.txt"
Get-AdfsDeviceRegistrationUpnSuffix | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsEndpoint.txt"
Get-AdfsEndpoint | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsFarmInformation.txt"
Get-AdfsFarmInformation | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsGlobalAuthenticationPolicy.txt"
Get-AdfsGlobalAuthenticationPolicy | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsGlobalWebContent.txt"
Get-AdfsGlobalWebContent | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsLocalClaimsProviderTrust.txt"
Get-AdfsLocalClaimsProviderTrust | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsNativeClientApplication.txt"
Get-AdfsNativeClientApplication | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsNonClaimsAwareRelyingPartyTrust.txt"
Get-AdfsNonClaimsAwareRelyingPartyTrust | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsProperties.txt"
Get-AdfsProperties | fl | Out-File $adfslog
Write-Output "======== WIASupportedUserAgents ==========" | Out-File $adfslog -Append
Get-AdfsProperties |select -ExpandProperty WIASupportedUserAgents | Out-File $adfslog -Append
$adfslog = $FolderName + "\Get-AdfsRegistrationHosts.txt"
Get-AdfsRegistrationHosts | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsRelyingPartyTrust.txt"
Get-AdfsRelyingPartyTrust | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsRelyingPartyTrustsGroup.txt"
Get-AdfsRelyingPartyTrustsGroup | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsRelyingPartyWebContent.txt"
Get-AdfsRelyingPartyWebContent | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsRelyingPartyWebTheme.txt"
Get-AdfsRelyingPartyWebTheme | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsScopeDescription.txt"
Get-AdfsScopeDescription | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsServerApplication.txt"
Get-AdfsServerApplication | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsSslCertificate.txt"
Get-AdfsSslCertificate | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsSyncProperties.txt"
Get-AdfsSyncProperties | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsTrustedFederationPartner.txt"
Get-AdfsTrustedFederationPartner | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsWebApiApplication.txt"
Get-AdfsWebApiApplication | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsWebApplicationProxyRelyingPartyTrust.txt"
Get-AdfsWebApplicationProxyRelyingPartyTrust | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsWebConfig.txt"
Get-AdfsWebConfig | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsWebTheme.txt"
Get-AdfsWebTheme | fl | Out-File $adfslog
$adfslog = $FolderName + "\netsh_ssl.txt"
netsh http show ssl > $adfslog
Write-Host "Completed gathering AD FS Config."
}
## WAP 4.0
if($WAPCheck -eq "true"){
Write-Host "Gathering WAP Config..."
$adfslog = $FolderName + "\ADFSAdmin.evtx"
wevtutil epl "AD FS/Admin" $adfslog
$adfslog = $FolderName + "\ADFSDebug.evtx"
wevtutil epl "AD FS Tracing/Debug" $adfslog
$adfslog = $FolderName + "\WAPAdmin.evtx"
wevtutil epl "Microsoft-Windows-WebApplicationProxy/Admin" $adfslog
$adfslog = $FolderName + "\Get-WebApplicationProxyApplication.txt"
Get-WebApplicationProxyApplication | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-WebApplicationProxyAvailableADFSRelyingParty.txt"
Get-WebApplicationProxyAvailableADFSRelyingParty | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-WebApplicationProxyConfiguration.txt"
Get-WebApplicationProxyConfiguration | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-WebApplicationProxyHealth.txt"
Get-WebApplicationProxyHealth | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-WebApplicationProxySslCertificate.txt"
Get-WebApplicationProxySslCertificate | fl | Out-File $adfslog
$adfslog = $FolderName + "\netsh_ssl.txt"
netsh http show ssl > $adfslog
Write-Host "Completed gathering WAP Config."
}
}
#20200217 追記/ Windows Server 2019 AD FS/WAP 用
if ($oschk -eq "W2k19"){
## AD FS 5.0
if($ADFSCheck -eq "true"){
Write-Host "Gathering AD FS Config..."
$adfslog = $FolderName + "\ADFSAdmin.evtx"
wevtutil epl "AD FS/Admin" $adfslog
$adfslog = $FolderName + "\ADFSDebug.evtx"
wevtutil epl "AD FS Tracing/Debug" $adfslog
$adfslog = $FolderName + "\Get-AdfsAccessControlPolicy.txt"
Get-AdfsAccessControlPolicy | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsAdditionalAuthenticationRule.txt"
Get-AdfsAdditionalAuthenticationRule | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsApplicationGroup.txt"
Get-AdfsApplicationGroup | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsApplicationPermission.txt"
Get-AdfsApplicationPermission | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsAttributeStore.txt"
Get-AdfsAttributeStore | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsAuthenticationProvider.txt"
Get-AdfsAuthenticationProvider | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsAuthenticationProviderWebContent.txt"
Get-AdfsAuthenticationProviderWebContent | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsAzureMfaConfigured.txt"
Get-AdfsAzureMfaConfigured | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsCertificate.txt"
Get-AdfsCertificate | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsCertificateAuthority.txt"
Get-AdfsCertificateAuthority | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsClaimDescription.txt"
Get-AdfsClaimDescription | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsClaimsProviderTrust.txt"
Get-AdfsClaimsProviderTrust | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsClaimsProviderTrustsGroup.txt"
Get-AdfsClaimsProviderTrustsGroup | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsClient.txt"
Get-AdfsClient | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsDeviceRegistration.txt"
Get-AdfsDeviceRegistration | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsDeviceRegistrationUpnSuffix.txt"
Get-AdfsDeviceRegistrationUpnSuffix | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsEndpoint.txt"
Get-AdfsEndpoint | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsFarmInformation.txt"
Get-AdfsFarmInformation | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsGlobalAuthenticationPolicy.txt"
Get-AdfsGlobalAuthenticationPolicy | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsGlobalWebContent.txt"
Get-AdfsGlobalWebContent | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsLocalClaimsProviderTrust.txt"
Get-AdfsLocalClaimsProviderTrust | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsNativeClientApplication.txt"
Get-AdfsNativeClientApplication | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsNonClaimsAwareRelyingPartyTrust.txt"
Get-AdfsNonClaimsAwareRelyingPartyTrust | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsProperties.txt"
Get-AdfsProperties | fl | Out-File $adfslog
Write-Output "======== WIASupportedUserAgents ==========" | Out-File $adfslog -Append
Get-AdfsProperties |select -ExpandProperty WIASupportedUserAgents | Out-File $adfslog -Append
$adfslog = $FolderName + "\Get-AdfsRegistrationHosts.txt"
Get-AdfsRegistrationHosts | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsRelyingPartyTrust.txt"
Get-AdfsRelyingPartyTrust | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsRelyingPartyTrustsGroup.txt"
Get-AdfsRelyingPartyTrustsGroup | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsRelyingPartyWebContent.txt"
Get-AdfsRelyingPartyWebContent | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsRelyingPartyWebTheme.txt"
Get-AdfsRelyingPartyWebTheme | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsScopeDescription.txt"
Get-AdfsScopeDescription | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsServerApplication.txt"
Get-AdfsServerApplication | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsSslCertificate.txt"
Get-AdfsSslCertificate | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsSyncProperties.txt"
Get-AdfsSyncProperties | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsTrustedFederationPartner.txt"
Get-AdfsTrustedFederationPartner | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsWebApiApplication.txt"
Get-AdfsWebApiApplication | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsWebApplicationProxyRelyingPartyTrust.txt"
Get-AdfsWebApplicationProxyRelyingPartyTrust | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsWebConfig.txt"
Get-AdfsWebConfig | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsWebTheme.txt"
Get-AdfsWebTheme | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsDebugLogConsumersConfiguration_Email.txt"
Get-AdfsDebugLogConsumersConfiguration -Consumer Email | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsDebugLogConsumersConfiguration_FileShare.txt"
Get-AdfsDebugLogConsumersConfiguration -Consumer FileShare | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsDirectoryProperties.txt"
Get-AdfsDirectoryProperties | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-AdfsThreatDetectionModule.txt"
Get-AdfsThreatDetectionModule | fl | Out-File $adfslog
$adfslog = $FolderName + "\netsh_ssl.txt"
netsh http show ssl > $adfslog
Write-Host "Completed gathering AD FS Config."
}
## WAP 5.0
if($WAPCheck -eq "true"){
Write-Host "Gathering WAP Config..."
$adfslog = $FolderName + "\ADFSAdmin.evtx"
wevtutil epl "AD FS/Admin" $adfslog
$adfslog = $FolderName + "\ADFSDebug.evtx"
wevtutil epl "AD FS Tracing/Debug" $adfslog
$adfslog = $FolderName + "\WAPAdmin.evtx"
wevtutil epl "Microsoft-Windows-WebApplicationProxy/Admin" $adfslog
$adfslog = $FolderName + "\Get-WebApplicationProxyApplication.txt"
Get-WebApplicationProxyApplication | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-WebApplicationProxyAvailableADFSRelyingParty.txt"
Get-WebApplicationProxyAvailableADFSRelyingParty | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-WebApplicationProxyConfiguration.txt"
Get-WebApplicationProxyConfiguration | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-WebApplicationProxyHealth.txt"
Get-WebApplicationProxyHealth | fl | Out-File $adfslog
$adfslog = $FolderName + "\Get-WebApplicationProxySslCertificate.txt"
Get-WebApplicationProxySslCertificate | fl | Out-File $adfslog
$adfslog = $FolderName + "\netsh_ssl.txt"
netsh http show ssl > $adfslog
Write-Host "Completed gathering WAP Config."
}
}
## 証明書情報取得
Write-Host "Gathering certutil logs..."
$certlog = $FolderName + "\cert-root.txt"
certutil -v -silent -store ROOT | Out-File $certlog
$certlog = $FolderName + "\cert-user-root.txt"
certutil -v -silent -store -user ROOT | Out-File $certlog
$certlog = $FolderName + "\cert-ca.txt"
certutil -v -silent -store CA | Out-File $certlog
$certlog = $FolderName + "\cert-authroot.txt"
certutil -v -silent -store AUTHROOT | Out-File $certlog
$certlog = $FolderName + "\cert-ent-roott.txt"
certutil -v -silent -store -enterprise ROOT | Out-File $certlog
$certlog = $FolderName + "\cert-ent-ntauth.txt"
certutil -v -silent -store -enterprise NTAUTH | Out-File $certlog
$certlog = $FolderName + "\cert-gp-root.txt"
certutil -v -silent -store -grouppolicy ROOT | Out-File $certlog
$certlog = $FolderName + "\cert-machine-my.txt"
certutil -v -silent -store MY | Out-File $certlog
$certlog = $FolderName + "\cert-user-my.txt"
certutil -v -silent -store -user MY | Out-File $certlog
$certlog = $FolderName + "\cert-adfstrusteddevices.txt"
certutil -v -silent -store AdfsTrustedDevices | Out-File $certlog
Write-Host "Completed gathering certutil logs."
## WAP の ProxyTrust 証明書の情報を取得
if($WAPCheck -eq "true"){
Write-Host "Gathering ProxyTrust certificate info..."
$CertHashFolder = "C:\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SystemCertificates\My\Certificates"
if(Test-Path $CertHashFolder) {
$WapCertsHash = $FolderName + "\wap-certs-hash.txt"
Get-ChildItem $CertHashFolder `
| Sort-Object -Property CreationTimeUtc -Descending `
| Select-Object Name, @{l="CreationTimeUtc";e={$_.CreationTimeUtc.ToString("yyyy-MM-ddThh:mm:ssZ")}} `
| ConvertTo-Csv -NoTypeInformation `
| Out-File $WapCertsHash
Write-Host "Completed gathering ProxyTrust certificate info."
}
}
## 2021/11/24 追加
## Http.err ログを取得
Write-Host "Gathering Http err logs..."
$HttplogFolder = $Env:SYSTEMROOT + "\system32\LogFiles\HTTPERR"
if(Test-Path $HttplogFolder) {
$HttplogOutPath = $FolderName + "\HttperrLogs"
Copy-Item $HttplogFolder -destination $HttplogOutPath -recurse
Write-Host "Completed gathering Http err logs."
}
Write-Host "Complate: Export Folder : " $FolderName
}
#######################開始処理#############################
#####管理者権限チェック。管理者権限でない場合に処理を終了する。
if (-not(([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))) {
Write-Host "Start PowerShell with adminisrator privilege."
exit
}
#####Startup 処理、[0] に OS バージョン情報を、 [1] に ProductType の値を入れる。 1=Client 2=DC 3=Server
$chk = startup
#####OS チェック、6.3 未満のビルドの場合は処理を終了する
if($chk[0] -eq "false"){
Write-Host "You have to run this script on Windows Server 2012 R2 or later version."
exit
}else{
#OS がバージョン通りであれば OSVersion と ProductType を提供してログ採取を開始する。
GetLog $chk[0] $chk[1]
}