-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGet-IntuneNetworkRequirements.ps1
More file actions
2834 lines (2783 loc) · 126 KB
/
Copy pathGet-IntuneNetworkRequirements.ps1
File metadata and controls
2834 lines (2783 loc) · 126 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
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
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#Requires -Version 7.0
<#
.SYNOPSIS
This script will test network connections to various Intune services using PowerShell 7
.DESCRIPTION
Welcome to the first release of INR - Intune Network Requirements. This script will allow you to test several different service areas
related to Intune. The main way this script is intended to run is not once, but at least **twice**.
**Requirements
* PowerShell 7
* RTFM https://manima.de/2024/08/intune-network-requirements-everything-i-learned/
* Admin rights (if you want to test your currently set NTP server)
Instructions:
1. Run the script on an unmanaged network, but ideally close to you or on the same provider.
2. Run the script using the same parameters on your managed network where you're experiencing issues
3. Run the script again (if necessary) to compare the two results and get a difference between the results.
This is the only way to reliably verify results. It is not possible to deterministically test the endpoints because there is no
documentation of which endpoint has which responses.
.PARAMETER TestAllServiceAreas
Specifies whether to test all target services.
.PARAMETER UseMSJSON
Specifies whether to use MSJSON for network requests.
.PARAMETER UseMS365JSON
Specifies whether to use MS365JSON for network requests.
.PARAMETER CustomURLFile
Recommended. Put this file next to the script. Specifies the path to the CSV file containing the URLs, ports, and protocols to test. The default value is "INRCustomList.csv".
.PARAMETER AllowBestEffort
Recommended. Specifies whether to allow best effort testing (will try to resolve wildcard URLs) for URLs that don't have an exact match.
.PARAMETER CheckCertRevocation
Recommended. Will verify if certificates that are presented by URLs are verified. This parameter _requires_ either -UseMSJSON, -UseMS365JSON or -CustomURLFile.
That is because the switch requires that one of following IDs is available:
125 = Common CRLs (available in MSJson and MS365JSON)
84 = Microsoft CRLs (available in MSJson and MS365JSON)
9993 = Custom CRLs (from INRCustomList.csv). If your custom list does not contain this ID, certificate revocation checks will not be possible.
.PARAMETER GCC
Will test the GCC specific URLs - this related to RemoteHelp and Device Health currently.
.PARAMETER Intune
Specifies whether to test all of the Intune service area (this merges a lot of different areas).
.PARAMETER Autopilot
Specifies whether to test all of the Autopilot service area (this merges a lot of different areas).
.PARAMETER WindowsActivation
Specifies whether to test the Windows Activation service area.
.PARAMETER EntraID
Specifies whether to test the EntraID service area.
.PARAMETER WindowsUpdate
Specifies whether to test the Windows Update service area.
.PARAMETER DeliveryOptimization
Specifies whether to test the Delivery Optimization service area.
.PARAMETER NTP
Specifies whether to test the NTP service area.
.PARAMETER DNS
Warning: This is not put into the result CSV. It will be available in the log. Specifies whether to test the DNS service area.
.PARAMETER DiagnosticsData
Specifies whether to test the Diagnostics Data service area.
.PARAMETER DiagnosticsDataUpload
Specifies whether to test the Diagnostics Data Upload service area.
.PARAMETER NCSI
Specifies whether to test the NCSI service area.
.PARAMETER WindowsNotificationService
Specifies whether to test the WindowsNotificationService service area.
.PARAMETER WindowsStore
Specifies whether to test the Windows Store service area.
.PARAMETER M365
Warning: This is a _lot_ of URLs and will run for a couple minutes. Specifies whether to test the M365 service area.
.PARAMETER CRLs
Specifies whether to test the CRLs service area. These are the well known CRLs by Microsoft, plus my own if you import the CSV.
.PARAMETER SelfDeploying
Specifies whether to test the self-deploying service area.
.PARAMETER RemoteHelp
Specifies whether to test the Remote Help service area.
.PARAMETER TPMAttestation
Specifies whether to test the TPM attestation service area.
.PARAMETER DeviceHealth
Specifies whether to test the device health service area.
.PARAMETER Apple
Specifies whether to test the Apple (iOS/iPadOS) service area.
.PARAMETER Android
Specifies whether to test the Android (Google) service area.
.PARAMETER EndpointAnalytics
Specifies whether to test the Endpoint Analytics service area.
.PARAMETER AppInstaller
Specifies whether to test the app installer (winget) service area.
.PARAMETER UniversalPrint
Specifies whether to test the universal print service area.
.PARAMETER ConnectedCache
Specifies whether to test the connected cache service area. Not included in TestAllServiceAreas.
.PARAMETER VisualStudioFull
Specifies whether to test all Visual Studio services. Not included in TestAllServiceAreas.
.PARAMETER VisualStudioInstallation
Will test all required endpoints for Visual Studio installation. Not included in TestAllServiceAreas.
.PARAMETER DefenderFull
Specifies whether to test the Defender Full service area. Not included in TestAllServiceAreas.
.PARAMETER DefenderOptional
Specifies whether to test the Defender Optional service area. Not included in TestAllServiceAreas.
.PARAMETER DefenderLiveResponse
Specifies whether to test the Defender Live Response service area. Not included in TestAllServiceAreas.
.PARAMETER DefenderVulnTool
Specifies whether to test the Defender Vulnerability Management service area. Not included in TestAllServiceAreas.
.PARAMETER DefenderSmartScreen
Specifies whether to test the Defender SmartScreen service area. Not included in TestAllServiceAreas.
.PARAMETER AppAndScript
Specifies whether to test the deployment domains for Win32, Windows script, macOS app and macOS script deployment.
.PARAMETER NuGet
Specifies whether to test for PowerShell Gallery with the default NuGet provider.
.PARAMETER TrustMeBro
Tests custom URL entries with ID 10000. This Custom-only test cannot be combined with another Artificial Service Area or Product and is not included in TestAllServiceAreas.
.PARAMETER AuthenticatedProxyOnly
Will test if there is an authenticated proxy in use - does not test other service areas.
.PARAMETER TestSSLInspectionOnly
Will test if there is any sort of SSL inspection - does not test other service areas.
.PARAMETER Legacy
This is not implemented yet. Specifies whether to test legacy service.
.PARAMETER TenantName
This must be specified if you want some of the M365 URLS to be populated automatically. This is the first part of your first <tenantname>.onmicrosoft.com
.PARAMETER MaxDelayInMS
Default: 300ms. This is my recommended value because some addresses tend to respond slowly.
.PARAMETER BurstMode
Will use the MaxDelayInMs, divide it into 50ms chunks and then do a quick test. Use this to find out response times.
.PARAMETER BrienMode
This mode allows you to run the script multiple times in succession and automatically merge the results. This can be used to
change network settings in between running the script with the same parameters. The last two results will be compared. Recommended
value: 2
.PARAMETER ProxyMode
Controls which connection routes are tested. Auto tests a direct connection and every distinct proxy detected from environment variables,
Windows Settings, and WinHTTP. Direct bypasses configured proxies. CurrentUser, WinHTTP, and Environment test only that source.
.PARAMETER MergeResults
Will trigger the result merge path. If two CSV files are in the working directory, it will merge those. Otherwise use -MergeCSVs.
.PARAMETER MergeShowAllResults
Will merge _all_ results not just differences.
.PARAMETER MergeCSVs
This will accept two CSV filesnames as strings. The files must be placed next to the script or the working directory (if specified differently).
.PARAMETER NoLog
Specifies whether to disable logging. This is a switch parameter.
.PARAMETER TestMethods
This is not implemented yet. This allows you to chose the test methods that the script will go through.
.PARAMETER OutputCSV
Output the results to a CSV file. This is not enabled by default. This is a recommended default switch.
.PARAMETER ShowResults
Shows the results in an Out-Gridview.
.PARAMETER ToConsole
Specifies whether to output log messages to the console. Enabling this won't create a log.
.PARAMETER WorkingDirectory
Specifies the working directory where the script will be executed. The default value is "C:\INR\".
.PARAMETER LogDirectory
Specifies the directory where log files will be stored. The default value is "C:\INR\".
.EXAMPLE
This example will use the MS-JSON for MEM, ingest the custom CSV if it exists in the same folder, allow wildcard
handling in URLS, check the CRLs of each certificate provided for the ASA TPM Attestation. The script will run twice,
asking you to change the network environment in between (e.g. from home to VPN), and then display all the results
of each pass and the merged results of the last two results.
.\Get-IntuneNetworkRequirements.ps1 -UseMSJSON -AllowBestEffort -CheckCertRevocation -ShowResults -TPMAttestation -BrienMode 2
.EXAMPLE
This example will use the MS-JSON for MEM, my custom CSV, allow for wildcard handling in URLS, check
the CRLs of each certificate provided for the ASA TPMAttestation and then display the results in a grid,
while displaying potential issues in the console for the service area TPMAttestation.
.\Get-IntuneNetworkRequirements.ps1 -UseMSJSON -CustomURLFile '.\INRCustomList.csv' -AllowBestEffort -CheckCertRevocation -TPMAttestation -ShowResults -ToConsole
.EXAMPLE
This will ingest 2 files from the working directory and compare them. The comparison is written to another CSV file while also showing the results in a grid view.
.\Get-IntuneNetworkRequirements.ps1 -MergeResults -MergeCSVs ResultList_29072024_110030_SADAME-PC.csv,ResultList_30072024_084101_3T0M4W3.csv -ShowResults
.EXAMPLE
This will test all Visual Studio endpoints and verify each CRL. It will output the results in a CSV file and show the results in a gridview.
.\Get-IntuneNetworkRequirements.ps1 -CustomURLFile .\VisualStudio.csv -UseMSJSON -CheckCertRevocation -VisualStudioFull -OutputCSV -ShowResults
.EXAMPLE
This will test all Defender endpoints and verify each CRL. It will output the results in a CSV file and show the results in a gridview.
.\Get-IntuneNetworkRequirements.ps1 -CustomURLFile .\MicrosoftDefender.csv -UseMSJSON -CheckCertRevocation -DefenderFull -OutputCSV -ShowResults
.NOTES
Version: 1.4.0
Versionname: Community-Is-Key
Intial creation date: 19.02.2024
Last change date: 03.11.2025
Latest changes: https://github.com/MHimken/toolbox/tree/main/Autopilot/MEMNetworkRequirements/changelog.md
Shoutouts:
* WinAdmins Community - especially Chris for helping me figure out some of the features.
* badssl.com and httpstat.us are awesome!
#>
[CmdletBinding()]
param(
#Main modes
[Parameter(ParameterSetName = 'AllAreas', Position = 1, Mandatory)]
[Parameter(ParameterSetName = 'TestMSJSON', Position = 0, Mandatory)]
[switch]$UseMSJSON,
[Parameter(ParameterSetName = 'AllAreas', Position = 2, Mandatory)]
[Parameter(ParameterSetName = 'TestMS365JSON', Position = 0, Mandatory)]
[switch]$UseMS365JSON,
[Parameter(ParameterSetName = 'AllAreas')]
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestMS365JSON')]
[Parameter(ParameterSetName = 'TestCustom', Position = 0, Mandatory)]
[Parameter(ParameterSetName = 'TrustMeBroOnly', Mandatory)]
[string]$CustomURLFile,
[Parameter(ParameterSetName = 'AllAreas', Position = 0, Mandatory)]
[switch]$TestAllServiceAreas,
#Options
[Parameter(ParameterSetName = 'AllAreas')]
[Parameter(ParameterSetName = 'TestMSJSON', Position = 1)]
[Parameter(ParameterSetName = 'TestMS365JSON')]
[Parameter(ParameterSetName = 'TestCustom', Position = 1)]
[Parameter(ParameterSetName = 'TrustMeBroOnly')]
[switch]$AllowBestEffort,
[Parameter(ParameterSetName = 'AllAreas')]
[Parameter(ParameterSetName = 'TestMSJSON', Position = 2)]
[Parameter(ParameterSetName = 'TestMS365JSON')]
[Parameter(ParameterSetName = 'TestCustom', Position = 2)]
[Parameter(ParameterSetName = 'TrustMeBroOnly')]
[switch]$CheckCertRevocation,
[Parameter(ParameterSetName = 'AllAreas')]
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$GCC,
#Artificial Service Areas
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$Intune,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$Autopilot,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$WindowsActivation,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$EntraID,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$WindowsUpdate,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$DeliveryOptimization,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$NTP,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$DNS,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$DiagnosticsData,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$DiagnosticsDataUpload,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$NCSI,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$WindowsNotificationService,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$WindowsStore,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestMS365JSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$M365,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$CRLs,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$SelfDeploying,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$RemoteHelp,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$TPMAttestation,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$DeviceHealth,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$Apple,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$Android,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$EndpointAnalytics,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$AppInstaller,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$UniversalPrint,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$AppAndScript,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$NuGet,
[Parameter(ParameterSetName = 'TrustMeBroOnly')]
[switch]$TrustMeBro,
#Products
#Connected Cache
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$ConnectedCache,
#Visual Studio
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$VisualStudioFull,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$VisualStudioInstallation,
#Defender
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$DefenderFull,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$DefenderOptional,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$DefenderLiveResponse,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$DefenderVulnTool,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$DefenderSmartScreen,
#Not Service area specific
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$AuthenticatedProxyOnly,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$TestSSLInspectionOnly,
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$Legacy,
#Special Methods
[Parameter(ParameterSetName = 'AllAreas', Mandatory)]
[Parameter(ParameterSetName = 'TestMS365JSON', Mandatory)]
[string]$TenantName,
[Parameter(ParameterSetName = 'AllAreas')]
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestMS365JSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[Parameter(ParameterSetName = 'TrustMeBroOnly')]
[int]$MaxDelayInMS = 300, # 300 is the minimum recommended due to some Microsoft services being heavy load (like MS Update)
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestMS365JSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[Parameter(ParameterSetName = 'TrustMeBroOnly')]
[switch]$BurstMode, # Divide the delay by 50 and try different speeds. Give warning when more than 10 URLs are tested
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestMS365JSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[Parameter(ParameterSetName = 'TrustMeBroOnly')]
[int]$BrienMode,
[Parameter(ParameterSetName = 'AllAreas')]
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestMS365JSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[Parameter(ParameterSetName = 'TrustMeBroOnly')]
[ValidateSet('Auto', 'Direct', 'CurrentUser', 'WinHTTP', 'Environment')]
[string]$ProxyMode = 'Auto',
#Merge options
[Parameter(ParameterSetName = 'Merge', Position = 0)]
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestMS365JSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$MergeResults,
[Parameter(ParameterSetName = 'Merge')]
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestMS365JSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[switch]$MergeShowAllResults,
[Parameter(ParameterSetName = 'Merge')]
[string[]]$MergeCSVs,
#Output options
[Parameter(ParameterSetName = 'AllAreas')]
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestMS365JSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[Parameter(ParameterSetName = 'Merge')]
[Parameter(ParameterSetName = 'TrustMeBroOnly')]
[switch]$OutputCSV,
[Parameter(ParameterSetName = 'AllAreas')]
[Parameter(ParameterSetName = 'TestMSJSON')]
[Parameter(ParameterSetName = 'TestMS365JSON')]
[Parameter(ParameterSetName = 'TestCustom')]
[Parameter(ParameterSetName = 'Merge')]
[Parameter(ParameterSetName = 'TrustMeBroOnly')]
[switch]$ShowResults,
#Common parameters
[switch]$NoOutput,
[switch]$ToConsole,
[System.IO.DirectoryInfo]$WorkingDirectory,
[System.IO.DirectoryInfo]$LogDirectory
)
#Preparation
if ($CheckCertRevocation -and -not($UseMSJSON -or $UseMS365JSON -or (Get-Content $CustomURLFile | Where-Object { $_ -match '9993' }))) {
Write-Output "If you want to check certificate revocation, please specify at least one source of URLs (-UseMSJSON, -UseMS365JSON or -CustomURLFile). Exiting script." -ForegroundColor Red
exit 1
}
function Get-ScriptPath {
<#
.SYNOPSIS
Get the current script path.
#>
if ($PSScriptRoot) {
# Console or VS Code debug/run button/F5 temp console
$ScriptRoot = $PSScriptRoot
} else {
if ($psISE) {
Split-Path -Path $psISE.CurrentFile.FullPath
} else {
if ($profile -match 'VScode') {
# VS Code "Run Code Selection" button/F8 in integrated console
$ScriptRoot = Split-Path $psEditor.GetEditorContext().CurrentFile.Path
} else {
Write-Output 'unknown directory to set path variable. exiting script.'
exit
}
}
}
$Script:PathToScript = $ScriptRoot
}
function ConvertTo-ProxyUri {
param(
[string]$ProxyList,
[ValidateSet('http', 'https')]
[string]$Scheme = 'https'
)
if ([string]::IsNullOrWhiteSpace($ProxyList)) {
return $null
}
$ProxyValue = $null
foreach ($Entry in $ProxyList -split ';') {
$Entry = $Entry.Trim()
if ($Entry -match '^(?<Scheme>https?|socks|socks4|socks5)=(?<Proxy>.+)$') {
if ($Matches.Scheme -eq $Scheme) {
$ProxyValue = $Matches.Proxy
break
}
} elseif (-not($ProxyValue)) {
$ProxyValue = $Entry
}
}
if ([string]::IsNullOrWhiteSpace($ProxyValue)) {
return $null
}
if ($ProxyValue -notmatch '^[a-z][a-z0-9+.-]*://') {
$ProxyValue = "http://$ProxyValue"
}
try {
$ProxyUri = [uri]$ProxyValue
if ($ProxyUri.Scheme -notin 'http', 'https') {
Write-Log -Message "Ignoring unsupported $($ProxyUri.Scheme) proxy '$ProxyValue'" -Component 'ProxyDiscovery' -Type 2
return $null
}
return $ProxyUri
} catch {
Write-Log -Message "Ignoring invalid proxy value '$ProxyValue'" -Component 'ProxyDiscovery' -Type 2
return $null
}
}
function Test-ProxyBypass {
param(
[uri]$TargetUri,
[string]$BypassList
)
if ([string]::IsNullOrWhiteSpace($BypassList)) {
return $false
}
foreach ($Entry in $BypassList -split '[;,]') {
$Pattern = $Entry.Trim()
if (-not($Pattern)) {
continue
}
if ($Pattern -eq '<local>' -and $TargetUri.Host -notmatch '\.') {
return $true
}
$Pattern = $Pattern -replace '^\.?\*', '*'
if ($TargetUri.Host -like $Pattern -or $TargetUri.AbsoluteUri -like $Pattern) {
return $true
}
}
return $false
}
function Get-EnvironmentProxyConfiguration {
param([ValidateSet('http', 'https')][string]$Scheme = 'https')
$ProxyValue = $null
$ProxyVariable = $null
foreach ($Name in @("$($Scheme.ToUpperInvariant())_PROXY", 'ALL_PROXY')) {
foreach ($Scope in @('Process', 'User', 'Machine')) {
$Value = [Environment]::GetEnvironmentVariable($Name, $Scope)
if ($Value) {
$ProxyValue = $Value
$ProxyVariable = "$Name ($Scope)"
break
}
}
if ($ProxyValue) {
break
}
}
if (-not($ProxyValue)) {
return $null
}
$NoProxy = $null
foreach ($Scope in @('Process', 'User', 'Machine')) {
$NoProxy = [Environment]::GetEnvironmentVariable('NO_PROXY', $Scope)
if ($NoProxy) {
break
}
}
[PSCustomObject]@{
Source = 'Environment'
ProxyUri = ConvertTo-ProxyUri -ProxyList $ProxyValue -Scheme $Scheme
BypassList = $NoProxy
Configuration = $ProxyVariable
}
}
function Get-WindowsProxyConfigurations {
if (-not('INR.NativeProxy' -as [type])) {
Add-Type -TypeDefinition @'
using System;
using System.Runtime.InteropServices;
namespace INR {
public static class NativeProxy {
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
private struct IEProxyConfig {
[MarshalAs(UnmanagedType.Bool)] public bool AutoDetect;
public IntPtr AutoConfigUrl;
public IntPtr Proxy;
public IntPtr ProxyBypass;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
private struct ProxyInfo {
public int AccessType;
public IntPtr Proxy;
public IntPtr ProxyBypass;
}
[DllImport("winhttp.dll", SetLastError = true, CharSet = CharSet.Unicode)]
private static extern bool WinHttpGetIEProxyConfigForCurrentUser(out IEProxyConfig config);
[DllImport("winhttp.dll", SetLastError = true, CharSet = CharSet.Unicode)]
private static extern bool WinHttpGetDefaultProxyConfiguration(out ProxyInfo config);
[DllImport("kernel32.dll")]
private static extern IntPtr GlobalFree(IntPtr memory);
private static string ReadAndFree(IntPtr value) {
if (value == IntPtr.Zero) return null;
string result = Marshal.PtrToStringUni(value);
GlobalFree(value);
return result;
}
public static string[] GetCurrentUser() {
IEProxyConfig config;
if (!WinHttpGetIEProxyConfigForCurrentUser(out config)) return null;
return new[] {
ReadAndFree(config.Proxy),
ReadAndFree(config.ProxyBypass),
ReadAndFree(config.AutoConfigUrl),
config.AutoDetect.ToString()
};
}
public static string[] GetWinHttp() {
ProxyInfo config;
if (!WinHttpGetDefaultProxyConfiguration(out config)) return null;
return new[] { ReadAndFree(config.Proxy), ReadAndFree(config.ProxyBypass) };
}
}
}
'@
}
$CurrentUser = [INR.NativeProxy]::GetCurrentUser()
$WinHttp = [INR.NativeProxy]::GetWinHttp()
[PSCustomObject]@{
CurrentUser = if ($CurrentUser) {
[PSCustomObject]@{
Source = 'CurrentUser'
ProxyList = $CurrentUser[0]
BypassList = $CurrentUser[1]
AutoConfigUrl = $CurrentUser[2]
AutoDetect = $CurrentUser[3] -eq 'True'
}
} else { $null }
WinHTTP = if ($WinHttp) {
[PSCustomObject]@{
Source = 'WinHTTP'
ProxyList = $WinHttp[0]
BypassList = $WinHttp[1]
}
} else { $null }
}
}
function Get-ProxyRoutes {
param(
[uri]$TargetUri,
[ValidateSet('Auto', 'Direct', 'CurrentUser', 'WinHTTP', 'Environment')]
[string]$Mode = $ProxyMode
)
$Routes = [System.Collections.Generic.List[object]]::new()
if ($Mode -in 'Auto', 'Direct') {
$Routes.Add([PSCustomObject]@{
ConnectionMethod = 'Direct'
ProxyAddress = $null
ProxyBypassed = $false
Configuration = 'Explicit direct connection'
})
}
$Scheme = if ($TargetUri.Scheme -eq 'http') { 'http' } else { 'https' }
$WindowsProxy = if ($Mode -in 'Auto', 'CurrentUser', 'WinHTTP') { Get-WindowsProxyConfigurations } else { $null }
$Configurations = @()
if ($Mode -in 'Auto', 'Environment') {
$EnvironmentProxy = Get-EnvironmentProxyConfiguration -Scheme $Scheme
if ($EnvironmentProxy) {
$Configurations += $EnvironmentProxy
}
}
if ($Mode -in 'Auto', 'CurrentUser' -and $WindowsProxy.CurrentUser) {
$CurrentUserProxyUri = ConvertTo-ProxyUri -ProxyList $WindowsProxy.CurrentUser.ProxyList -Scheme $Scheme
if (-not($CurrentUserProxyUri) -and ($WindowsProxy.CurrentUser.AutoConfigUrl -or $WindowsProxy.CurrentUser.AutoDetect)) {
try {
$ResolvedProxyUri = [System.Net.WebRequest]::GetSystemWebProxy().GetProxy($TargetUri)
if ($ResolvedProxyUri -and $ResolvedProxyUri.AbsoluteUri -ne $TargetUri.AbsoluteUri) {
$CurrentUserProxyUri = $ResolvedProxyUri
}
} catch {
Write-Log -Message "Current-user automatic proxy resolution failed for $TargetUri`: $($_.Exception.Message)" -Component 'ProxyDiscovery' -Type 2
}
}
$Configurations += [PSCustomObject]@{
Source = 'CurrentUser'
ProxyUri = $CurrentUserProxyUri
BypassList = $WindowsProxy.CurrentUser.BypassList
Configuration = if ($WindowsProxy.CurrentUser.AutoConfigUrl) { "PAC: $($WindowsProxy.CurrentUser.AutoConfigUrl)" } elseif ($WindowsProxy.CurrentUser.AutoDetect) { 'WPAD enabled' } else { 'Windows Settings' }
}
}
if ($Mode -in 'Auto', 'WinHTTP' -and $WindowsProxy.WinHTTP) {
$Configurations += [PSCustomObject]@{
Source = 'WinHTTP'
ProxyUri = ConvertTo-ProxyUri -ProxyList $WindowsProxy.WinHTTP.ProxyList -Scheme $Scheme
BypassList = $WindowsProxy.WinHTTP.BypassList
Configuration = 'WinHTTP default proxy'
}
}
$RouteKeys = [System.Collections.Generic.HashSet[string]]::new([StringComparer]::OrdinalIgnoreCase)
foreach ($Configuration in $Configurations) {
if (-not($Configuration.ProxyUri)) {
continue
}
$ProxyBypassed = Test-ProxyBypass -TargetUri $TargetUri -BypassList $Configuration.BypassList
$RouteKey = "$($Configuration.ProxyUri.AbsoluteUri.TrimEnd('/'))|$ProxyBypassed"
if ($Mode -eq 'Auto' -and -not($RouteKeys.Add($RouteKey))) {
Write-Log -Message "Skipping duplicate $($Configuration.Source) proxy route $($Configuration.ProxyUri)" -Component 'ProxyDiscovery'
continue
}
$Routes.Add([PSCustomObject]@{
ConnectionMethod = $Configuration.Source
ProxyAddress = $Configuration.ProxyUri.AbsoluteUri.TrimEnd('/')
ProxyBypassed = $ProxyBypassed
Configuration = $Configuration.Configuration
})
}
if (-not($Routes.Count)) {
throw "ProxyMode '$Mode' did not resolve to an available proxy configuration for $TargetUri."
}
return $Routes
}
function Invoke-RoutedWebRequest {
param(
[uri]$Uri,
[ValidateSet('Get', 'Head')]
[string]$Method = 'Get',
[switch]$SkipHttpErrorCheck
)
$Errors = [System.Collections.Generic.List[string]]::new()
foreach ($Route in Get-ProxyRoutes -TargetUri $Uri) {
$Parameters = @{
Uri = $Uri
Method = $Method
ConnectionTimeoutSeconds = [Math]::Max(1, [Math]::Ceiling($MaxDelayInMS / 100))
}
if ($SkipHttpErrorCheck) {
$Parameters.SkipHttpErrorCheck = $true
}
if ($Route.ConnectionMethod -eq 'Direct' -or $Route.ProxyBypassed) {
$Parameters.NoProxy = $true
} else {
$Parameters.Proxy = $Route.ProxyAddress
}
try {
return [PSCustomObject]@{
Response = Invoke-WebRequest @Parameters
Route = $Route
}
} catch {
$Errors.Add("$($Route.ConnectionMethod): $($_.Exception.Message)")
Write-Log -Message "Request to $Uri failed using $($Route.ConnectionMethod): $($_.Exception.Message)" -Component 'RoutedWebRequest' -Type 2
}
}
throw "Request to $Uri failed using every selected route: $($Errors -join '; ')"
}
function Initialize-Script {
<#
.SYNOPSIS
Will initialize most of the required variables throughout this script.
#>
#Prepare environment
Get-ScriptPath
$Script:DateTime = Get-Date -Format yyyyMMdd_HHmmss
if (-not($Script:CurrentLocation)) {
$Script:CurrentLocation = Get-Location
}
if (-not($WorkingDirectory)) {
$WorkingDirectory = $Script:PathToScript
} else {
if (-not(Test-Path $WorkingDirectory )) { New-Item $WorkingDirectory -ItemType Directory -Force | Out-Null }
}
if ((Get-Location).path -ne $WorkingDirectory) {
Set-Location $WorkingDirectory
}
if (-not($LogDirectory)) {
$LogDirectory = Join-Path -Path $WorkingDirectory -ChildPath "Logs"
}
if (-not(Test-Path $LogDirectory )) { New-Item $LogDirectory -ItemType Directory -Force | Out-Null }
if ($OutputCSV) {
$Script:OutpathFilePath = $(Join-Path $WorkingDirectory -ChildPath "TestResults")
if (-not(Test-Path $Script:OutpathFilePath)) { New-Item $Script:OutpathFilePath -ItemType Directory -Force | Out-Null }
}
if (-not($Script:LogFile)) {
$LogPrefix = 'INR'
$Script:LogFile = Join-Path -Path $LogDirectory -ChildPath ('{0}_{1}.log' -f $LogPrefix, $Script:DateTime)
if (-not(Test-Path $LogDirectory)) { New-Item $LogDirectory -ItemType Directory -Force | Out-Null }
}
if ($PSVersionTable.psversion.major -lt 7) {
Write-Log -Message 'Please follow the manual - PowerShell 7 is currently required to run this script.' -Component 'InitializeScript' -Type 3
Exit 1
}
#Create lists
$Script:GUID = (New-Guid).Guid
$Script:M365ServiceURLs = [System.Collections.ArrayList]::new()
$Script:WildCardURLs = [System.Collections.ArrayList]::new()
$Script:CRLURLsToCheck = [System.Collections.ArrayList]::new()
$Script:URLsToVerify = [System.Collections.ArrayList]::new()
$Script:DNSCache = [System.Collections.ArrayList]::new()
$Script:TCPCache = [System.Collections.ArrayList]::new()
if ($Script:FinalResultList) {
Get-Variable FinalResultList | Clear-Variable
}
$Script:FinalResultList = [System.Collections.ArrayList]::new()
try {
$ExternalIPRequest = Invoke-RoutedWebRequest -Uri 'https://geo-prod.do.dsp.mp.microsoft.com/geo'
$Script:ExternalIP = (ConvertFrom-Json $ExternalIPRequest.Response.Content).ExternalIpAddress
Write-Log -Message "External IP: $($Script:ExternalIP) (via $($ExternalIPRequest.Route.ConnectionMethod))" -Component 'InitializeScript'
} catch {
Write-Log -Message "External IP lookup failed: $($_.Exception.Message)" -Component 'InitializeScript' -Type 2
}
#Initialize custom Script variables
Import-CustomURLFile
if ($UseMSJSON) {
Get-M365Service -MEM
}
if ($UseMS365JSON) {
Get-M365Service -M365
}
if ($Script:ManualURLs -and -not($UseMSJSON -or $UseMS365JSON -or ($Script:ManualURLs | Where-Object { $_.ID -eq 9993 })) -and $CheckCertRevocation) {
Write-Log 'CheckCertRevocation requires a list of known CRLs, either add your own in the custom CSV (with ID 9993) or specify -UseMSJSON or -UseMS365JSON' -Component 'InitializeScript' -Type 3
Write-Log 'This will cause to show "SSLInseption = True" for _all_ results!' -Component 'InitializeScript' -Type 3
}
if (-not($Script:M365ServiceURLs) -and -not($Script:ManualURLs) -and -not($MergeResults)) {
Write-Log 'No domains have been imported, please specify -UseMSJSON, -UseMS365JSON or -CustomURLFile' -Component 'InitializeScript' -Type 3
exit 5
}
}
function Write-Log {
<#
.DESCRIPTION
This is a (heavily) modified version of the script by Ryan Ephgrave.
.LINK
https://www.ephingadmin.com/powershell-cmtrace-log-function/
#>
Param (
[Parameter(Mandatory = $false)]
$Message,
$Component,
# Type: 1 = Normal, 2 = Warning (yellow), 3 = Error (red)
[ValidateSet('1', '2', '3')][int]$Type
)
if (-not($NoOutput)) {
$Time = Get-Date -Format 'HH:mm:ss.ffffff'
$Date = Get-Date -Format 'MM-dd-yyyy'
if (-not($Component)) { $Component = 'Runner' }
if (-not($ToConsole)) {
$LogMessage = "<![LOG[$Message" + "]LOG]!><time=`"$Time`" date=`"$Date`" component=`"$Component`" context=`"`" type=`"$Type`" thread=`"`" file=`"`">"
$LogMessage | Out-File -Append -Encoding UTF8 -FilePath $LogFile
} elseif ($ToConsole) {
switch ($type) {
1 { Write-Host "T:$Type C:$Component M:$Message" }
2 { Write-Host "T:$Type C:$Component M:$Message" -BackgroundColor Yellow -ForegroundColor Black }
3 { Write-Host "T:$Type C:$Component M:$Message" -BackgroundColor Red -ForegroundColor White }
default { Write-Host "T:$Type C:$Component M:$Message" }
}
}
}
}
function Write-SettingsToLog {
if (-not($MergeResults)) {
Write-Log "Settings used to run the script:
General settings
TestAllServiceAreas: $TestAllServiceAreas
UseMSJSON: $UseMSJSON
UseMS365JSON: $UseMS365JSON
CustomURLFile: $CustomURLFile
AllowBestEffort: $AllowBestEffort
CheckCertRevocation: $CheckCertRevocation
GCC: $GCC
ASAs
Intune: $Intune
Autopilot: $Autopilot
WindowsActivation: $WindowsActivation
EntraID: $EntraID
WindowsUpdate: $WindowsUpdate
DeliveryOptimization: $DeliveryOptimization
NTP: $NTP
DNS: $DNS
DiagnosticsData: $DiagnosticsData
DiagnosticsDataUpload: $DiagnosticsDataUpload
NCSI: $NCSI
WindowsNotificationService: $WindowsNotificationService
WindowsStore: $WindowsStore
M365: $M365
CRLs: $CRLs
SelfDeploying: $SelfDeploying
RemoteHelp: $RemoteHelp
TPMAttestation: $TPMAttestation
DeviceHealth: $DeviceHealth
Apple: $Apple
Android: $Android
EndpointAnalytics: $EndpointAnalytics
AppInstaller: $AppInstaller
UniversalPrint: $UniversalPrint
AppAndScript: $AppAndScript
TrustMeBro: $TrustMeBro
Products
VisualStudioFull: $VisualStudioFull
VisualStudioInstallation: $VisualStudioInstallation
DefenderFull: $DefenderFull
DefenderOptional: $DefenderOptional
DefenderSmartScreen: $DefenderSmartScreen
DefenderLiveResponse: $DefenderLiveResponse
DefenderVulnTool: $DefenderVulnTool
Other tests
AuthenticatedProxyOnly: $AuthenticatedProxyOnly
TestSSLInspectionOnly: $TestSSLInspectionOnly
Legacy: $Legacy
Additional Settings
TenantName: $TenantName
MaxDelayInMS: $MaxDelayInMS
BurstMode: $BurstMode" -Component 'InitialzeScript'
} else {
Write-Log "Settings used to run the script:
Merge options
MergeResults: $MergeResults
MergeShowAllResults: $MergeShowAllResults
MergeCSVs: $MergeCSVs" -Component 'InitialzeScript'
}
Write-Log "Output options
OutputCSV: $OutputCSV
ShowResults: $ShowResults
Common parameters
NoLog: $NoLog
ToConsole: $ToConsole
WorkingDirectory: $WorkingDirectory
LogDirectory: $LogDirectory
BrienMode: $BrienMode
ProxyMode: $ProxyMode
ScriptPath: $($Script:PathToScript)
LogFile: $($Script:LogFile)" -Component 'InitialzeScript'
}
function Import-CustomURLFile {
<#
.SYNOPSIS
Imports URLs from a custom CSV file. Automatically uses 'INRCustomList.csv' if no filename is specified.
#>
if (-not($CustomURLFile)) {
Write-Log 'No CSV provided - trying autodetect for filename ' -Component 'ImportCustomURLFile'
$DefaultCSVName = "INRCustomList.csv"
$JoinedDefaultCSVPath = Join-Path $Script:PathToScript -ChildPath $DefaultCSVName
if (Test-Path $JoinedDefaultCSVPath) {
Write-Log "CSV found in $($Script:PathToScript)" -Component 'ImportCustomURLFile'
$CustomURLFile = $DefaultCSVName
} else {
Write-Log 'Autodetection did not find a custom CSV file' -Component 'ImportCustomURLFile'
return
}
}
Write-Log 'Adding custom URLs to the pool' -Component 'ImportCustomURLFile'
$Header = 'URL', 'Port', 'Protocol', 'ID'
$Script:ManualURLs = [System.Collections.ArrayList]::new()
$TempObjects = Import-Csv -Path (Join-Path -Path $Script:PathToScript -ChildPath $CustomURLFile) -Delimiter ',' -Header $Header
foreach ($Object in $TempObjects) {
$URLObject = [PSCustomObject]@{
id = $Object.ID
#serviceArea = $Object.serviceArea
#serviceAreaDisplayName = $Object.serviceAreaDisplayName
url = $Object.url.replace('*.', '')
Port = $Object.port
Protocol = $Object.protocol
#expressRoute = $Object.expressRoute
#category = $Object.category
required = 'true'
#notes = $Object.notes
}
$Script:ManualURLs.add($URLObject) | Out-Null
}
}
function Get-URLsFromID {
<#
.SYNOPSIS
Will put the URLs for different service areas into one big arraylist.
#>
param(
[int[]]$IDs,
[int[]]$FilterPort
)
if ($Script:URLsToVerify) {
Get-Variable URLsToVerify | Clear-Variable
$Script:URLsToVerify = [System.Collections.ArrayList]::new()
}
foreach ($ID in $IDs) {
if ($Script:ManualURLs) {
$Script:ManualURLs | Where-Object { $_.id -eq $ID -and $_.port -notin $FilterPort } | ForEach-Object { $Script:URLsToVerify.Add($_) | Out-Null }
}
if ($Script:M365ServiceURLs) {
$Script:M365ServiceURLs | Where-Object { $_.id -eq $ID -and $_.port -notin $FilterPort } | ForEach-Object { $Script:URLsToVerify.Add($_) | Out-Null }
}
if (-not($Script:URLsToVerify)) {
return $false
}
$DuplicateURLsToVerify = [System.Collections.ArrayList]::new()
foreach ($IDsFound in $Script:URLsToVerify) {
$RemoveMe = $Script:URLsToVerify | Where-Object { $_.id -eq $IDsFound.id -and $_.url -eq $IDsFound.url -and $_.port -eq $IDsFound.port -and $_.protocol -eq $IDsFound.protocol }
if ($RemoveMe.count -gt 1) {
$counter = 0
foreach ($RemoveObject in $RemoveMe) {
if ($counter -gt 0) {
$DuplicateURLsToVerify.add($RemoveObject) | Out-Null
}
$counter++
}
}
}
$DuplicateURLsToVerify | ForEach-Object { $Script:URLsToVerify.Remove($_) }
}
return $true
}
#Import M365 Service-URLs
function Find-WildcardURL {
<#
.SYNOPSIS
Will resolve wildcards to actual URLs. If AllowBestEffort is set might also remove the wildcards from URLs if they can't be matched otherwise
#>
Write-Log -Message 'Now searching for nearest match for Wildcards' -Component 'FindWildcardURL'
foreach ($Object in $Script:WildCardURLs) {
Write-Log -Message "Searching for $($Object.url)" -Component 'FindWildcardURL'
if ($($Script:M365ServiceURLs | Where-Object { $_.url -like "*$($Object.url.replace('*.',''))*" })) {
continue
}
$ReplaceElement = $Object.url.split('.')[0]
if ($ReplaceElement -ne '*') {
$WildcardReplacement = $ReplaceElement.replace('*', 'INR')
$NewURL = $Object.url.replace($ReplaceElement, $WildcardReplacement)
} else {
$NewURL = $Object.url.replace('*.', '')
}