-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathGet-AADAudit.ps1
711 lines (681 loc) · 34.6 KB
/
Get-AADAudit.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
# .\Get-AADAudit.ps1 -AuditPath 'X:\temp' -IncludeRAW -CliXMLPath 'C:\Users\tauze\OneDrive\04_Repos\Projekty_prywatne\Private\AADSecurity\CertificateThumbprint.xml' -SecretCliXMLPath "C:\Users\tauze\OneDrive\04_Repos\Projekty_prywatne\Private\AADSecurity\AppSecret.xml" -ApplicationID 'bf43dc83-2fb1-4cd6-80a0-fb34696379c6' -TenantID '56b759c4-70fd-4f95-8a65-88d5ca311666'
<#
.NOTES
All rigts reserved to
Robert Przybylski
www.azureblog.pl
robert(at)azureblog.pl
2022
.EXAMPLE
.\Get-AADAudit.ps1 -AuditPath 'X:\temp' -CliXMLPath 'Path_to_your_xml_file_with_thumbprint' -SecretCliXMLPath 'Path_to_your_xml_file_with_appsecret' -ApplicationID 'Your_App_ID' -TenantID 'Your_Tenant_ID' -IncludeRAW
Transcript started, output file is X:\temp\AAD_Audit\MVP Tenant\AAD_Audit_21_11_2022_1854.log
###############################################
# Starging DATA Collection #
# Scripts Version: 1.1 #
###############################################
Welcome To Microsoft Graph!
----> Running Get-AADAccessReviews script
Connecting to MS Graph
Found '8' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_AccessReviews_11_21_2022.csv'
----> Running Get-AADAdminConsent script
Connecting to MS Graph
Found '1' entries
Exporting entries to file: 'AAD_AdminConsent_11_21_2022.csv'
----> Running Get-AADAdministrativeUnits script
Connecting to MS Graph
Found '2' entries
Exporting entries to file: 'AAD_AdministrativeUnits_11_21_2022.csv'
----> Running Get-AADApplications script
Connecting to MS Graph
Found '7' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_Applications_11_21_2022.csv'
----> Running Get-AADAuthenticationMethods script
Working on URI 'https://graph.microsoft.com/v1.0/authenticationMethodsPolicy'
Found '5' entries
Exporting entries to file: 'AAD_AuthenticationMethods_11_21_2022.csv'
----> Running Get-AADDevices script
Connecting to MS Graph
Found '10' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_Devices_11_21_2022.csv'
----> Running Get-AADDomains script
Connecting to MS Graph
Found '3' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_Domains_11_21_2022.csv'
----> Running Get-AADGroups script
Connecting to MS Graph
Found '16' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_Groups_11_21_2022.csv'
----> Running Get-AADNamedLocations script
Connecting to MS Graph
Found '1' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_NamedLocations_11_21_2022.csv'
----> Running Get-AADRiskDetection script
Connecting to MS Graph
Found '2' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_RiskDetection_11_21_2022.csv'
----> Running Get-AADRiskyUsers script
Connecting to MS Graph
Found '2' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_RiskyUsers_11_21_2022.csv'
----> Running Get-AADRoles script
Connecting to MS Graph
Found '13' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_Roles_11_21_2022.csv'
----> Running Get-AADSecureScore script
Connecting to MS Graph
WARNING: 199 - "Microsoft/SecureScore/500/10047"
Found '0' entries under 'mvp.azureblog.pl' tenant
No entries found, no file to be created.
----> Running Get-AADServicePrincipals script
Connecting to MS Graph
Found '100' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_ServicePrincipals_11_21_2022.csv'
----> Running Get-AADTermsOfUse script
Connecting to MS Graph
Found '1' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_TermsOfUse_11_21_2022.csv'
----> Running Get-AADUsers script
Connecting to MS Graph
Found '19' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_Users_11_21_2022.csv'
----> Running Get-CAPolicySetup script
Connecting to MS Graph
Found '7' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_ConditionalAccessPolicySetup_11_21_2022.csv'
----> Running Get-CloudBGA script
Connecting to MS Graph
Fount '1' entries
Exporting entries to file: 'AAD_PotentialBreakGlassSetup_11_21_2022.csv'
###############################################
# Starging RAW DATA Collection #
# Scripts Version: 1.1 #
###############################################
----> Collecting RAW data in json files.
Working on URI 'https://graph.microsoft.com/v1.0/devices'
Working on URI 'https://graph.microsoft.com/v1.0/directoryRoles'
Working on URI 'https://graph.microsoft.com/v1.0/domains'
Working on URI 'https://graph.microsoft.com/v1.0/groupSettings'
Working on URI 'https://graph.microsoft.com/v1.0/users'
Working on URI 'https://graph.microsoft.com/v1.0/directoryRoles'
Working on URI 'https://graph.microsoft.com/v1.0/identity/conditionalAccess/policies'
Working on URI 'https://graph.microsoft.com/v1.0/identityGovernance/accessReviews/definitions'
Working on URI 'https://graph.microsoft.com/v1.0/identityGovernance/entitlementManagement'
Working on URI 'https://graph.microsoft.com/v1.0/identityGovernance/termsOfUse/agreements'
Working on URI 'https://graph.microsoft.com/v1.0/authenticationMethodsPolicy'
Working on URI 'https://graph.microsoft.com/v1.0/policies/identitySecurityDefaultsEnforcementPolicy'
Working on URI 'https://graph.microsoft.com/v1.0/subscribedSkus'
Working on URI 'https://graph.microsoft.com/v1.0/identity/conditionalAccess/namedLocations'
Working on URI 'https://graph.microsoft.com/v1.0/directory/administrativeUnits'
Working on URI 'https://graph.microsoft.com/v1.0/authenticationMethodsPolicy'
Working on URI 'https://graph.microsoft.com/v1.0/policies/crossTenantAccessPolicy/partners'
Working on URI 'https://graph.microsoft.com/v1.0/policies/crossTenantAccessPolicy/default'
Working on URI 'https://graph.microsoft.com/v1.0/policies/adminConsentRequestPolicy'
Transcript stopped, output file is X:\temp\AAD_Audit\MVP Tenant\AAD_Audit_21_11_2022_1854.log
.EXAMPLE
.\Get-AADAudit.ps1 -AuditPath 'X:\temp' -CliXMLPath 'Path_to_your_xml_file_with_thumbprint' -SecretCliXMLPath 'Path_to_your_xml_file_with_appsecret' -ApplicationID 'Your_App_ID' -TenantID 'Your_Tenant_ID'
Transcript started, output file is X:\temp\AAD_Audit\MVP Tenant\AAD_Audit_21_11_2022_1856.log
###############################################
# Starging DATA Collection #
# Scripts Version: 1.1 #
###############################################
Welcome To Microsoft Graph!
----> Running Get-AADAccessReviews script
Connecting to MS Graph
Found '8' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_AccessReviews_11_21_2022.csv'
----> Running Get-AADAdminConsent script
Connecting to MS Graph
Found '1' entries
Exporting entries to file: 'AAD_AdminConsent_11_21_2022.csv'
----> Running Get-AADAdministrativeUnits script
Connecting to MS Graph
Found '2' entries
Exporting entries to file: 'AAD_AdministrativeUnits_11_21_2022.csv'
----> Running Get-AADApplications script
Connecting to MS Graph
Found '7' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_Applications_11_21_2022.csv'
----> Running Get-AADAuthenticationMethods script
Working on URI 'https://graph.microsoft.com/v1.0/authenticationMethodsPolicy'
Found '5' entries
Exporting entries to file: 'AAD_AuthenticationMethods_11_21_2022.csv'
----> Running Get-AADDevices script
Connecting to MS Graph
Found '10' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_Devices_11_21_2022.csv'
----> Running Get-AADDomains script
Connecting to MS Graph
Found '3' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_Domains_11_21_2022.csv'
----> Running Get-AADGroups script
Connecting to MS Graph
Found '16' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_Groups_11_21_2022.csv'
----> Running Get-AADNamedLocations script
Connecting to MS Graph
Found '1' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_NamedLocations_11_21_2022.csv'
----> Running Get-AADRiskDetection script
Connecting to MS Graph
Found '2' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_RiskDetection_11_21_2022.csv'
----> Running Get-AADRiskyUsers script
Connecting to MS Graph
Found '2' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_RiskyUsers_11_21_2022.csv'
----> Running Get-AADRoles script
Connecting to MS Graph
Found '13' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_Roles_11_21_2022.csv'
----> Running Get-AADSecureScore script
Connecting to MS Graph
WARNING: 199 - "Microsoft/SecureScore/502/90"
Found '0' entries under 'mvp.azureblog.pl' tenant
No entries found, no file to be created.
----> Running Get-AADServicePrincipals script
Connecting to MS Graph
Found '100' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_ServicePrincipals_11_21_2022.csv'
----> Running Get-AADTermsOfUse script
Connecting to MS Graph
Found '1' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_TermsOfUse_11_21_2022.csv'
----> Running Get-AADUsers script
Connecting to MS Graph
Found '19' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_Users_11_21_2022.csv'
----> Running Get-CAPolicySetup script
Connecting to MS Graph
Found '7' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_ConditionalAccessPolicySetup_11_21_2022.csv'
----> Running Get-CloudBGA script
Connecting to MS Graph
Fount '1' entries
Exporting entries to file: 'AAD_PotentialBreakGlassSetup_11_21_2022.csv'
Transcript stopped, output file is X:\temp\AAD_Audit\MVP Tenant\AAD_Audit_21_11_2022_1856.log
.Example
.\Get-AADAudit.ps1 -AuditPath 'X:\temp' -CliXMLPath 'Path_to_your_xml_file_with_thumbprint' -SecretCliXMLPath 'Path_to_your_xml_file_with_appsecret' -ApplicationID 'Your_App_ID' -TenantID 'Your_Tenant_ID' -IncludeRAW -Verbose
###############################################
# Starging DATA Collection #
# Scripts Version: 1.1 #
###############################################
Welcome To Microsoft Graph!
----> Running Get-AADAccessReviews script
VERBOSE: FileName: 'AAD_AccessReviews'
VERBOSE: OutputPath: 'X:\temp\AAD_Audit\MVP Tenant'
VERBOSE: CertificateThumbprint: 'XXXX'
VERBOSE: ApplicationId: 'XXXX'
VERBOSE: TenantID: 'XXXX'
VERBOSE: TenantDomainName: 'mvp.azureblog.pl'
Connecting to MS Graph
Found '8' entries under 'mvp.azureblog.pl' tenant
VERBOSE: Working on 'Review guest access across Microsoft 365 groups 2'
VERBOSE: Working on 'one time review'
VERBOSE: Working on 'Review guest access across Microsoft 365 groups'
VERBOSE: Working on 'Review guest access across Microsoft 365 groups'
VERBOSE: Working on 'AccessPackage1 - Initial Policy'
VERBOSE: Working on 'mvp_graph review'
VERBOSE: Working on 'group review '
VERBOSE: Working on 'graph api for powershell '
Exporting entries to file: 'AAD_AccessReviews_11_21_2022.csv'
----> Running Get-AADAdminConsent script
VERBOSE: FileName: 'AAD_AdminConsent'
VERBOSE: OutputPath: 'X:\temp\AAD_Audit\MVP Tenant'
VERBOSE: CertificateThumbprint: 'XXXX'
VERBOSE: ApplicationId: 'XXXX'
VERBOSE: TenantID: 'XXXX'
VERBOSE: TenantDomainName: 'mvp.azureblog.pl'
Connecting to MS Graph
Found '1' entries
Exporting entries to file: 'AAD_AdminConsent_11_21_2022.csv'
----> Running Get-AADAdministrativeUnits script
VERBOSE: FileName: 'AAD_AdministrativeUnits'
VERBOSE: OutputPath: 'X:\temp\AAD_Audit\MVP Tenant'
VERBOSE: CertificateThumbprint: 'XXXX'
VERBOSE: ApplicationId: 'XXXX'
VERBOSE: TenantID: 'XXXX'
VERBOSE: TenantDomainName: 'mvp.azureblog.pl'
Connecting to MS Graph
Found '2' entries
VERBOSE: Working on 'TEST' Admnistrative Unit
VERBOSE: Working on 'SSS' Admnistrative Unit
Exporting entries to file: 'AAD_AdministrativeUnits_11_21_2022.csv'
----> Running Get-AADApplications script
VERBOSE: FileName: 'AAD_Applications'
VERBOSE: OutputPath: 'X:\temp\AAD_Audit\MVP Tenant'
VERBOSE: CertificateThumbprint: 'XXXX'
VERBOSE: ApplicationId: 'XXXX'
VERBOSE: TenantID: 'XXXX'
VERBOSE: TenantDomainName: 'mvp.azureblog.pl'
Connecting to MS Graph
Found '7' entries under 'mvp.azureblog.pl' tenant
VERBOSE: Working on 'P2P Server'
VERBOSE: Working on 'mvp.azureblog.pl'
VERBOSE: Working on 'MVP-graph'
VERBOSE: Working on 'AzureBlog-Bicep-SponsorshipMVP'
VERBOSE: Working on 'AzureBlog-Bicep-XXXX'
VERBOSE: Working on 'AADAssessment'
VERBOSE: Working on 'AzureBlog-Bicep-XXXX'
Exporting entries to file: 'AAD_Applications_11_21_2022.csv'
----> Running Get-AADAuthenticationMethods script
VERBOSE: FileName: 'AAD_AuthenticationMethods'
VERBOSE: OutputPath: 'X:\temp\AAD_Audit\MVP Tenant'
VERBOSE: SecretCliXMLPath: 'XXXX\AppSecret.xml'
VERBOSE: CertificateThumbprint: 'XXXX'
VERBOSE: ApplicationId: 'XXXX'
VERBOSE: TenantID: 'XXXX'
VERBOSE: Uri: 'https://graph.microsoft.com/v1.0/authenticationMethodsPolicy'
VERBOSE: TenantDomainName: 'mvp.azureblog.pl'
VERBOSE: POST with -1-byte payload
VERBOSE: received 2412-byte response of content type application/json; charset=utf-8
Working on URI 'https://graph.microsoft.com/v1.0/authenticationMethodsPolicy'
VERBOSE: GET with 0-byte payload
VERBOSE: received -1-byte response of content type
application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
VERBOSE: Working on 'Fido2'
VERBOSE: Working on 'MicrosoftAuthenticator'
VERBOSE: Working on 'TemporaryAccessPass'
VERBOSE: Working on 'Email'
VERBOSE: Working on 'X509Certificate'
Found '5' entries
Exporting entries to file: 'AAD_AuthenticationMethods_11_21_2022.csv'
----> Running Get-AADDevices script
VERBOSE: FileName: 'AAD_Devices'
VERBOSE: OutputPath: 'X:\temp\AAD_Audit\MVP Tenant'
VERBOSE: CertificateThumbprint: 'XXXX'
VERBOSE: ApplicationId: 'XXXX'
VERBOSE: TenantID: 'XXXX'
VERBOSE: TenantDomainName: 'mvp.azureblog.pl'
Connecting to MS Graph
Found '10' entries under 'mvp.azureblog.pl' tenant
VERBOSE: Working on 'vm-pco5-neu-1'
VERBOSE: Working on 'samsungSM-G980F'
VERBOSE: Working on 'vm-aadjoined-ne'
VERBOSE: Working on 'vm-pco5-neu-0'
VERBOSE: Working on 'vm-pco5-neu-1'
VERBOSE: Working on 'vm-0'
VERBOSE: Working on 'vm-pco5-neu-0'
VERBOSE: Working on 'vm-pco1-neu'
VERBOSE: Working on 'vm-pco-neu-0'
VERBOSE: Working on 'vm-pco-neu-1'
Exporting entries to file: 'AAD_Devices_11_21_2022.csv'
----> Running Get-AADDomains script
VERBOSE: FileName: 'AAD_Domains'
VERBOSE: OutputPath: 'X:\temp\AAD_Audit\MVP Tenant'
VERBOSE: CertificateThumbprint: 'XXXX'
VERBOSE: ApplicationId: 'XXXX'
VERBOSE: TenantID: 'XXXX'
VERBOSE: TenantDomainName: 'mvp.azureblog.pl'
Connecting to MS Graph
Found '3' entries under 'mvp.azureblog.pl' tenant
VERBOSE: Working on 'XXXX'
VERBOSE: Working on 'mvp.azureblog.pl'
VERBOSE: Working on 'XXXX'
Exporting entries to file: 'AAD_Domains_11_21_2022.csv'
----> Running Get-AADGroups script
VERBOSE: FileName: 'AAD_Groups'
VERBOSE: OutputPath: 'X:\temp\AAD_Audit\MVP Tenant'
VERBOSE: CertificateThumbprint: 'XXXX'
VERBOSE: ApplicationId: 'XXXX'
VERBOSE: TenantID: 'XXXX'
VERBOSE: TenantDomainName: 'mvp.azureblog.pl'
Connecting to MS Graph
Found '16' entries under 'mvp.azureblog.pl' tenant
VERBOSE: Working on 'AAD DC Administrators'
VERBOSE: Working on 'Microsoft 365 E5 Developer (without Windows and Audio Conferencing)'
VERBOSE: Working on 'Privileged_users'
VERBOSE: Working on 'Azure ATP mvpazureblog Users'
VERBOSE: Working on 'Subscription_contributors'
VERBOSE: Working on 'Passwordless'
VERBOSE: Working on 'External_Collaboration'
VERBOSE: Working on 'MVP Tenant'
VERBOSE: Working on 'Collaboration_with_partners'
VERBOSE: Working on 'Azure ATP mvpazureblog Viewers'
VERBOSE: Working on 'Azure ATP mvpazureblog Administrators'
VERBOSE: Working on 'Subscription_Owners'
VERBOSE: Working on 'Sponsored_Subscription_Owners'
VERBOSE: Working on 'ZeroTrust'
VERBOSE: Working on 'Catalog_Creators'
VERBOSE: Working on 'Sponsored_Subscription_contributors'
Exporting entries to file: 'AAD_Groups_11_21_2022.csv'
----> Running Get-AADNamedLocations script
VERBOSE: FileName: 'AAD_NamedLocations'
VERBOSE: OutputPath: 'X:\temp\AAD_Audit\MVP Tenant'
VERBOSE: CertificateThumbprint: 'XXXX'
VERBOSE: ApplicationId: 'XXXX'
VERBOSE: TenantID: 'XXXX'
VERBOSE: TenantDomainName: 'mvp.azureblog.pl'
Connecting to MS Graph
Found '1' entries under 'mvp.azureblog.pl' tenant
VERBOSE: Working on 'XXXX'
Exporting entries to file: 'AAD_NamedLocations_11_21_2022.csv'
----> Running Get-AADRiskDetection script
VERBOSE: FileName: 'AAD_RiskDetection'
VERBOSE: OutputPath: 'X:\temp\AAD_Audit\MVP Tenant'
VERBOSE: CertificateThumbprint: 'XXXX'
VERBOSE: ApplicationId: 'XXXX'
VERBOSE: TenantID: 'XXXX'
VERBOSE: TenantDomainName: 'mvp.azureblog.pl'
Connecting to MS Graph
Found '2' entries under 'mvp.azureblog.pl' tenant
VERBOSE: Working on 'XXXX'
VERBOSE: Working on 'XXXX'
Exporting entries to file: 'AAD_RiskDetection_11_21_2022.csv'
----> Running Get-AADRiskyUsers script
VERBOSE: FileName: 'AAD_RiskyUsers'
VERBOSE: OutputPath: 'X:\temp\AAD_Audit\MVP Tenant'
VERBOSE: CertificateThumbprint: 'XXXX'
VERBOSE: ApplicationId: 'XXXX'
VERBOSE: TenantID: 'XXXX'
VERBOSE: TenantDomainName: 'mvp.azureblog.pl'
Connecting to MS Graph
Found '2' entries under 'mvp.azureblog.pl' tenant
VERBOSE: Working on 'XXX'
VERBOSE: Working on 'XXXX'
Exporting entries to file: 'AAD_RiskyUsers_11_21_2022.csv'
----> Running Get-AADRoles script
VERBOSE: FileName: 'AAD_Roles'
VERBOSE: OutputPath: 'X:\temp\AAD_Audit\MVP Tenant'
VERBOSE: CertificateThumbprint: 'XXXX'
VERBOSE: ApplicationId: 'XXXX'
VERBOSE: TenantID: 'XXXX'
VERBOSE: TenantDomainName: 'mvp.azureblog.pl'
Connecting to MS Graph
Found '13' entries under 'mvp.azureblog.pl' tenant
VERBOSE: Working on 'SharePoint Administrator'
VERBOSE: Working on 'Azure AD Joined Device Local Administrator'
VERBOSE: Working on 'Intune Administrator'
VERBOSE: Working on 'Cloud Device Administrator'
VERBOSE: Working on 'Conditional Access Administrator'
VERBOSE: Working on 'Authentication Administrator'
VERBOSE: Working on 'User Administrator'
VERBOSE: Working on 'Directory Readers'
VERBOSE: Working on 'Global Administrator'
VERBOSE: Working on '[email protected]'
VERBOSE: Working on 'Password Administrator'
VERBOSE: Working on 'Security Administrator'
VERBOSE: Working on 'Application Administrator'
VERBOSE: Working on '[email protected]'
VERBOSE: Working on 'Directory Synchronization Accounts'
VERBOSE: Working on 'ADToAADSyncServiceAccount@XXXX'
Exporting entries to file: 'AAD_Roles_11_21_2022.csv'
----> Running Get-AADSecureScore script
VERBOSE: FileName: 'AAD_SecureScore'
VERBOSE: OutputPath: 'X:\temp\AAD_Audit\MVP Tenant'
VERBOSE: CertificateThumbprint: 'XXXX'
VERBOSE: ApplicationId: 'XXXX'
VERBOSE: TenantID: 'XXXX'
VERBOSE: TenantDomainName: 'mvp.azureblog.pl'
Connecting to MS Graph
Found '1' entries under 'mvp.azureblog.pl' tenant
Exporting entries to file: 'AAD_SecureScore_11_21_2022.csv'
----> Running Get-AADServicePrincipals script
VERBOSE: FileName: 'AAD_ServicePrincipals'
VERBOSE: OutputPath: 'X:\temp\AAD_Audit\MVP Tenant'
VERBOSE: CertificateThumbprint: 'XXXX'
VERBOSE: ApplicationId: 'XXXX'
VERBOSE: TenantID: 'XXXX'
VERBOSE: TenantDomainName: 'mvp.azureblog.pl'
Connecting to MS Graph
Found '100' entries under 'mvp.azureblog.pl' tenant
VERBOSE: Working on 'XXXX'
VERBOSE: Working on 'XXXX'
VERBOSE: Working on 'XXXX'
Exporting entries to file: 'AAD_ServicePrincipals_11_21_2022.csv'
----> Running Get-AADTermsOfUse script
VERBOSE: FileName: 'AAD_TermsOfUse'
VERBOSE: OutputPath: 'X:\temp\AAD_Audit\MVP Tenant'
VERBOSE: CertificateThumbprint: 'XXXX'
VERBOSE: ApplicationId: 'XXXX'
VERBOSE: TenantID: 'XXXX'
VERBOSE: TenantDomainName: 'mvp.azureblog.pl'
Connecting to MS Graph
Found '1' entries under 'mvp.azureblog.pl' tenant
VERBOSE: Working on 'MVP AzureBlog Terms of use'
Exporting entries to file: 'AAD_TermsOfUse_11_21_2022.csv'
----> Running Get-AADUsers script
VERBOSE: FileName: 'AAD_Users'
VERBOSE: OutputPath: 'X:\temp\AAD_Audit\MVP Tenant'
VERBOSE: CertificateThumbprint: 'XXXX'
VERBOSE: ApplicationId: 'XXXX'
VERBOSE: TenantID: 'XXXX'
VERBOSE: TenantDomainName: 'mvp.azureblog.pl'
Connecting to MS Graph
Found '19' entries under 'mvp.azureblog.pl' tenant
VERBOSE: Working on 'On-Premises Directory Synchronization Service Account'
VERBOSE: Working on 'Agnieszka'
VERBOSE: Working on 'BlackPanter'
VERBOSE: Working on 'Black Widow'
VERBOSE: Working on 'Bruce Banner'
VERBOSE: Working on 'Capitan America'
VERBOSE: Working on 'Drax'
VERBOSE: Working on 'Im Groot'
VERBOSE: Working on 'Justin Case'
VERBOSE: Working on 'Loki'
VERBOSE: Working on 'PasswordLessTester'
VERBOSE: Working on 'Robert'
VERBOSE: Working on 'Rocket Raccoon'
VERBOSE: Working on 'Robert Przybylski'
VERBOSE: Working on 'Robert Przybylski [BG]'
VERBOSE: Working on 'Test User 1'
VERBOSE: Working on 'Test User 2'
VERBOSE: Working on 'Test User 3'
Exporting entries to file: 'AAD_Users_11_21_2022.csv'
----> Running Get-CAPolicySetup script
VERBOSE: FileName: 'AAD_ConditionalAccessPolicySetup'
VERBOSE: OutputPath: 'X:\temp\AAD_Audit\MVP Tenant'
VERBOSE: CertificateThumbprint: 'XXXX'
VERBOSE: ApplicationId: 'XXXX'
VERBOSE: TenantID: 'XXXX'
VERBOSE: TenantDomainName: 'mvp.azureblog.pl'
Connecting to MS Graph
Found '7' entries under 'mvp.azureblog.pl' tenant
VERBOSE: Working on '[ZeroTrust] Require ToU for external users' policy
VERBOSE: Working on '[ZeroTrust] Block legacy authentication methods' policy
VERBOSE: Working on '[ZeroTrust] Device Assurance Win10 - Compliance State' policy
VERBOSE: Working on '[ZeroTrust] Microsoft Cloud App Security - monitroing & blocking actions' policy
VERBOSE: Working on 'External Users and Guests - MVP AzureBlog Terms of use' policy
VERBOSE: Working on 'Block Countires' policy
VERBOSE: Working on 'test' policy
Exporting entries to file: 'AAD_ConditionalAccessPolicySetup_11_21_2022.csv'
----> Running Get-CloudBGA script
VERBOSE: FileName: 'AAD_PotentialBreakGlassSetup'
VERBOSE: DirectoryRoleId: 'b54c6a04-043c-4769-821b-86576a6bca34'
VERBOSE: OutputPath: 'X:\temp\AAD_Audit\MVP Tenant'
VERBOSE: CertificateThumbprint: 'XXXX'
VERBOSE: ApplicationId: 'XXXX'
VERBOSE: TenantID: 'XXXX'
VERBOSE: TenantDomainName: 'mvp.azureblog.pl'
Connecting to MS Graph
VERBOSE: Found new entry - 'XXXX' that meets criteria for member of AAD role 'Global Administrator'
with id 'b54c6a04-043c-4769-821b-86576a6bca34' in '' tenant
VERBOSE: Updating BGA array
Fount '1' entries
Exporting entries to file: 'AAD_PotentialBreakGlassSetup_11_21_2022.csv'
###############################################
# Starging RAW DATA Collection #
# Scripts Version: 1.1 #
###############################################
----> Collecting RAW data in json files.
VERBOSE: OutputPath: 'X:\temp\AAD_Audit\MVP Tenant\RAW'
VERBOSE: SecretCliXMLPath: 'XXXX\AppSecret.xml'
VERBOSE: ApplicationID: 'XXXX'
VERBOSE: TenantID: 'XXXX'
VERBOSE: TenantDomainName: 'mvp.azureblog.pl'
VERBOSE: DebugMe: ''
VERBOSE: POST with -1-byte payload
VERBOSE: received 2412-byte response of content type application/json; charset=utf-8
Working on URI 'https://graph.microsoft.com/v1.0/devices'
VERBOSE: GET with 0-byte payload
VERBOSE: received -1-byte response of content type
application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Working on URI 'https://graph.microsoft.com/v1.0/directoryRoles'
VERBOSE: GET with 0-byte payload
VERBOSE: received -1-byte response of content type
application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Working on URI 'https://graph.microsoft.com/v1.0/domains'
VERBOSE: GET with 0-byte payload
VERBOSE: received -1-byte response of content type
application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Working on URI 'https://graph.microsoft.com/v1.0/groupSettings'
VERBOSE: GET with 0-byte payload
VERBOSE: received -1-byte response of content type
application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Working on URI 'https://graph.microsoft.com/v1.0/users'
VERBOSE: GET with 0-byte payload
VERBOSE: received -1-byte response of content type
application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Working on URI 'https://graph.microsoft.com/v1.0/directoryRoles'
VERBOSE: GET with 0-byte payload
VERBOSE: received -1-byte response of content type
application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Working on URI 'https://graph.microsoft.com/v1.0/identity/conditionalAccess/policies'
VERBOSE: GET with 0-byte payload
VERBOSE: received -1-byte response of content type
application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Working on URI 'https://graph.microsoft.com/v1.0/identityGovernance/accessReviews/definitions'
VERBOSE: GET with 0-byte payload
VERBOSE: received -1-byte response of content type
application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Working on URI 'https://graph.microsoft.com/v1.0/identityGovernance/entitlementManagement'
VERBOSE: GET with 0-byte payload
VERBOSE: received -1-byte response of content type
application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Working on URI 'https://graph.microsoft.com/v1.0/identityGovernance/termsOfUse/agreements'
VERBOSE: GET with 0-byte payload
VERBOSE: received -1-byte response of content type
application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Working on URI 'https://graph.microsoft.com/v1.0/authenticationMethodsPolicy'
VERBOSE: GET with 0-byte payload
VERBOSE: received -1-byte response of content type
application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Working on URI 'https://graph.microsoft.com/v1.0/policies/identitySecurityDefaultsEnforcementPolicy'
VERBOSE: GET with 0-byte payload
VERBOSE: received -1-byte response of content type
application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Working on URI 'https://graph.microsoft.com/v1.0/subscribedSkus'
VERBOSE: GET with 0-byte payload
VERBOSE: received -1-byte response of content type
application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Working on URI 'https://graph.microsoft.com/v1.0/identity/conditionalAccess/namedLocations'
VERBOSE: GET with 0-byte payload
VERBOSE: received -1-byte response of content type
application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Working on URI 'https://graph.microsoft.com/v1.0/directory/administrativeUnits'
VERBOSE: GET with 0-byte payload
VERBOSE: received -1-byte response of content type
application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Working on URI 'https://graph.microsoft.com/v1.0/authenticationMethodsPolicy'
VERBOSE: GET with 0-byte payload
VERBOSE: received -1-byte response of content type
application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Working on URI 'https://graph.microsoft.com/v1.0/policies/crossTenantAccessPolicy/partners'
VERBOSE: GET with 0-byte payload
VERBOSE: received -1-byte response of content type application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Working on URI 'https://graph.microsoft.com/v1.0/policies/crossTenantAccessPolicy/default'
VERBOSE: GET with 0-byte payload
VERBOSE: received -1-byte response of content type application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Working on URI 'https://graph.microsoft.com/v1.0/policies/adminConsentRequestPolicy'
VERBOSE: GET with 0-byte payload
VERBOSE: received -1-byte response of content type application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
#>
[CmdletBinding()]
param (
[Parameter(Position = 0, mandatory = $true)]
[string] $AuditPath,
[Parameter(Position = 1, mandatory = $true)]
[string] $CliXMLPath,
[Parameter(Position = 2, mandatory = $true)]
[string] $SecretCliXMLPath,
[Parameter(Position = 3, mandatory = $true)]
[string] $ApplicationID ,
[Parameter(Position = 4, mandatory = $true)]
[string] $TenantID,
[Parameter(Position = 5)]
[switch] $IncludeRAW
)
$scriptsVersion = '1.1'
$rawVersion = '1.1'
#region initial setup
try {
Stop-Transcript
}
catch {
}
$auditFolderTest = Test-Path $AuditPath
if ($auditFolderTest -eq $false) {
New-Item -Path $AuditPath -Name AAD_Audit -ItemType Directory -Force | Out-Null
}
$certificateThumbprint = (Import-CliXml -Path $CliXMLPath).GetNetworkCredential().Password
try {
Get-AZTenant | out-null
}
catch {
Connect-AzAccount
}
$tenantName = (Get-AZTenant).name
$tenantAuditPath = "$AuditPath\AAD_Audit\$tenantName"
$tenantFolderTest = Test-Path $tenantAuditPath
if ($tenantFolderTest -eq $false) {
New-Item -path "$AuditPath\AAD_Audit" -Name $tenantName -ItemType Directory -Force | Out-Null
}
$oldLocation = Get-Location
#endregion
#region transcript
$date = Get-Date -Format "dd_MM_yyyy_HHmm"
$transcriptPath = "$tenantAuditPath\AAD_Audit_$($date).log"
Start-Transcript -Path $transcriptPath
#endregion
#region Audit Scripts run
Write-Host ""
Write-Host "###############################################" -ForegroundColor Blue
Write-Host "# " -ForegroundColor Blue -NoNewline
Write-Host "Starging DATA Collection" -NoNewline
Write-Host " #" -ForegroundColor Blue
Write-Host "# " -ForegroundColor Blue -NoNewline
Write-Host "Scripts Version: " -NoNewline
Write-Host "$scriptsVersion #" -ForegroundColor Blue
Write-Host "###############################################" -ForegroundColor Blue
Write-Host ""
Connect-MgGraph -CertificateThumbprint $certificateThumbprint -ClientId $ApplicationID -TenantId $TenantID
$tenantDomainName = (Get-MgDomain | Where-Object { $_.IsDefault -eq $true }).id
$scripts = Get-ChildItem -Path .\Scripts\ -File
foreach ($entry in $scripts) {
$fileName = $entry.Name
$fileNameClean = [io.path]::GetFileNameWithoutExtension($fileName)
write-Host "----> Running $fileNameClean script" -ForegroundColor Blue
if ($VerbosePreference -eq 'Continue') {
. .\Scripts\$fileName -OutputPath $tenantAuditPath -SecretCliXMLPath $SecretCliXMLPath -CertificateThumbprint $certificateThumbprint -ApplicationId $ApplicationID -TenantId $TenantID -TenantDomainName $tenantDomainName -Verbose
}
else {
. .\Scripts\$fileName -OutputPath $tenantAuditPath -SecretCliXMLPath $SecretCliXMLPath -CertificateThumbprint $certificateThumbprint -ApplicationId $ApplicationID -TenantId $TenantID -TenantDomainName $tenantDomainName
}
}
#end region
if ($IncludeRAW) {
Write-Host ""
Write-Host "###############################################" -ForegroundColor Blue
Write-Host "# " -ForegroundColor Blue -NoNewline
Write-Host "Starging RAW DATA Collection" -NoNewline
Write-Host " #" -ForegroundColor Blue
Write-Host "# " -ForegroundColor Blue -NoNewline
Write-Host "Scripts Version: " -NoNewline
Write-Host "$rawVersion #" -ForegroundColor Blue
Write-Host "###############################################" -ForegroundColor Blue
Write-Host ""
$rawPath = "$tenantAuditPath\RAW"
$rawTest = test-path $rawPath
if ($rawTest -eq $false ) {
New-Item -path "$tenantAuditPath" -Name RAW -ItemType Directory -Force | Out-Null
}
write-Host "----> Collecting RAW data in json files." -ForegroundColor Blue
if ($VerbosePreference -eq 'Continue') {
. .\Get-AADRawData.ps1 -OutputPath $rawPath -SecretCliXMLPath $SecretCliXMLPath -ApplicationID $ApplicationID -CertificateThumbprint $certificateThumbprint -TenantId $TenantID -TenantDomainName $TenantDomainName -Verbose
}
else {
. .\Get-AADRawData.ps1 -OutputPath $rawPath -SecretCliXMLPath $SecretCliXMLPath -ApplicationID $ApplicationID -CertificateThumbprint $certificateThumbprint -TenantId $TenantID -TenantDomainName $TenantDomainName
}
}
Stop-Transcript
Set-Location $oldLocation