-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathIntune.xml
5421 lines (4224 loc) · 241 KB
/
Intune.xml
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
<?xml version="1.0" encoding="utf-8"?>
<DataPoints xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:Microsoft.One.DataCollector">
<Package ID="Intune">
<Commands>
<Command Type="PS" Team="General" OutputFileName="NA">$outputPath = "$env:temp\CollectedData\Intune\Commands\General"
$x = if (-not (Test-Path $outputPath)) { mkdir $outputPath -Force}
msinfo32.exe /NFO "$outputPath\msinfo32.nfo"
msinfo32.exe /report "$outputPath\msinfo32.txt"
</Command>
<Command Type="PS" Team="Autopilot" OutputFileName="NA">
$outputPath = "$env:temp\CollectedData\Intune\Commands\Autopilot"
# Event 100 is returned if no AP XML file was found
$NumLogs = ( Get-WinEvent -LogName "Microsoft-Windows-ModernDeployment-Diagnostics-Provider/Autopilot" | Where-Object { $_.Id -ne 100} ).count
# we are on an AP-enrolled device
if ($NumLogs -gt 0) {
mdmdiagnosticstool.exe -area "DeviceEnrollment;DeviceProvisioning;Autopilot" -zip "$outputPath\MDMDiagReport-AutopilotDeviceProvisioningDeviceEnrollment.zip"
}
else {
Write-Output "Skipping AP log collection"
}
</Command>
<Command Type="PS" Team="General" OutputFileName="dsreg_status">dsregcmd /status</Command>
<Command Type="PS" Team="General" OutputFileName="whoami">RunCommand "whoami"
RunCommand "whoami /upn"
RunCommand "whoami /all"
RunCommand "whoami /logonid"
RunCommand "whoami /fqdn"</Command>
<Command Type="PS" Team="General" OutputFileName="NA">
# dsregcmd_debug. Must be ran as system
$ErrorActionPreference = "Stop"
$Error.Clear()
$line = "`*" * 120
function WaitOnSchTask {
param([string]$taskName, [string]$OutFile = "$env:SystemRoot\temp\dsregcmd_debug.txt" )
[int]$timer = 0
try {
"waiting on $taskName to complete" | Out-file $OutFile -Force -Append -Encoding ascii
$status = (Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue).State
while ( ($status -ne "Ready") -and ($timer -le 150) ) {
"status: $status. waiting on $taskName to complete" | Out-file $OutFile -Force -Append -Encoding ascii
$status = (Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue).State
$timer += 5
Start-Sleep 5
}
}
catch [Microsoft.PowerShell.Cmdletization.Cim.CimJobException] {
"Something went wrong. Scheduled task not found" | Out-file $OutFile -Force -Append -Encoding ascii
}
catch {
"Something went wrong." | Out-file $OutFile -Force -Append -Encoding ascii
$Error[0] | Out-file $OutFile -Force -Append -Encoding ascii
$Error[0].Exception.GetType().fullname | Out-file $OutFile -Force -Append -Encoding ascii
}
}
$TimeToRun = (Get-Date ).AddSeconds(3)
$folderPath = "$env:temp\CollectedData\Intune\Commands\General"
$filepath = Join-Path $folderPath "$($env:COMPUTERNAME)_dsregcmd_debug.txt"
$timeStamp = (Get-Date).ToString("ddMMyyyyhhmmss")
$taskName = "ODC DsregCmd Debug - $timeStamp"
$Trigger = New-ScheduledTaskTrigger -At $TimeToRun -Once
$User = "NT AUTHORITY\SYSTEM"
$desc = "Scheduled task created by Intune One Data Collector."
# Create folder if it does not exist for uploader
if ( -not ( Test-Path $folderPath -ErrorAction SilentlyContinue) ) {
$nil = mkdir $folderPath -Force
}
$line | Out-File $filepath -Force -Encoding ascii
"Starting dsregcmd /debug using Scheduled Task as SYSTEM`r`n" | Out-File $filepath -Append -Force -Encoding ascii
$line | Out-File $filepath -Force -Append -Encoding ascii
try {
$Action= New-ScheduledTaskAction -Execute "cmd.exe" -Argument "/c dsregcmd /debug >> $filepath"
$nil = Register-ScheduledTask -TaskName $taskName -Trigger $Trigger -User $User -Action $Action -RunLevel Highest –Force
$nil = Start-ScheduledTask -TaskName $taskName
# wait for task to complete
sleep 10
WaitOnSchTask -taskName $taskName -OutFile $filepath
#cleanup
$nil = Unregister-ScheduledTask -TaskName $taskName -TaskPath "\" -PassThru -Confirm:$false -ErrorAction SilentlyContinue
}
catch {
"Something went wrong." | Out-file $filepath -Force -Append -Encoding ascii
$Error[0] | Out-file $filepath -Force -Append -Encoding ascii
$Error[0].Exception.GetType().fullname | Out-file $filepath -Force -Append -Encoding ascii
}
#cleanup
try {
foreach ($taskName in $(( Get-ScheduledTask -TaskPath "\" | Where-Object {$_.TaskName -match "ODC Windows Update Debug" }).TaskName) ){
"Unregistering $taskName" | Out-file $filepath -Force -Append -Encoding ascii
$nil = Unregister-ScheduledTask -TaskName "$taskName" -TaskPath "\" -PassThru -Confirm:$false
}
Get-ScheduledTask -TaskPath "\" | Where-Object {$_.TaskName -match "ODC DsregCmd Debug" } | Out-file $filepath -Force -Append -Encoding ascii
}
catch {
"***Warning: Unable to remove scheduled task $taskName. Please delete this entry from Task Scheduler" | Out-file $filepath -Force -Append -Encoding ascii
$Error[0] | Out-file $filepath -Force -Append -Encoding ascii
$Error[0].Exception.GetType().fullname | Out-file $filepath -Force -Append -Encoding ascii
}
</Command>
<Command Type="PS" Team="General" OutputFileName="BasicSystemInfo.txt">
Function GetAgeDescription($TimeSpan, [switch] $Localized) {
$Age = $TimeSpan
if ($Age.Days -gt 0)
{
$AgeDisplay = $Age.Days.ToString()
if ($Age.Days -gt 1)
{
if ($Localized.IsPresent)
{
$AgeDisplay += " " + $UtilsCTSStrings.ID_Days
}
else
{
$AgeDisplay += " Days"
}
}
else
{
if ($Localized.IsPresent)
{
$AgeDisplay += " " + $UtilsCTSStrings.ID_Day
}
else
{
$AgeDisplay += " Day"
}
}
}
else
{
if ($Age.Hours -gt 0)
{
if ($AgeDisplay.Length -gt 0) {$AgeDisplay += " "}
$AgeDisplay = $Age.Hours.ToString()
if ($Age.Hours -gt 1)
{
if ($Localized.IsPresent)
{
$AgeDisplay += " " + $UtilsCTSStrings.ID_Hours
}
else
{
$AgeDisplay += " Hours"
}
}
else
{
if ($Localized.IsPresent)
{
$AgeDisplay += " " + $UtilsCTSStrings.ID_Hour
}
else
{
$AgeDisplay += " Hour"
}
}
}
if ($Age.Minutes -gt 0)
{
if ($AgeDisplay.Length -gt 0) {$AgeDisplay += " "}
$AgeDisplay += $Age.Minutes.ToString()
if ($Age.Minutes -gt 1)
{
if ($Localized.IsPresent)
{
$AgeDisplay += " " + $UtilsCTSStrings.ID_Minutes
}
else
{
$AgeDisplay += " Minutes"
}
}
else
{
if ($Localized.IsPresent)
{
$AgeDisplay += " " + $UtilsCTSStrings.ID_Minute
}
else
{
$AgeDisplay += " Minute"
}
}
}
if ($Age.Seconds -gt 0)
{
if ($AgeDisplay.Length -gt 0) {$AgeDisplay += " "}
$AgeDisplay += $Age.Seconds.ToString()
if ($Age.Seconds -gt 1)
{
if ($Localized.IsPresent)
{
$AgeDisplay += " " + $UtilsCTSStrings.ID_Seconds
}
else
{
$AgeDisplay += " Seconds"
}
}
else
{
if ($Localized.IsPresent)
{
$AgeDisplay += " " + $UtilsCTSStrings.ID_Second
}
else
{
$AgeDisplay += " Second"
}
}
}
if (($Age.TotalSeconds -lt 1))
{
if ($AgeDisplay.Length -gt 0) {$AgeDisplay += " "}
$AgeDisplay += $Age.TotalSeconds.ToString()
if ($Localized.IsPresent)
{
$AgeDisplay += " " + $UtilsCTSStrings.ID_Seconds
}
else
{
$AgeDisplay += " Seconds"
}
}
}
Return $AgeDisplay
}
$OS_Summary = new-object PSObject # Operating System Summary
$CS_Summary = new-object PSObject # Computer System Summary
$WMIOS = $null
$error.Clear()
$WMIOS = get-wmiobject -class "win32_operatingsystem" -ErrorAction SilentlyContinue
if ($Error.Count -ne 0) {
$errorMessage = $Error[0].Exception.Message
$errorCode = "0x{0:X}" -f $Error[0].Exception.ErrorCode
"Error" + $errorCode + ": $errorMessage connecting to $MachineName" | WriteTo-StdOut
$Error.Clear()
}
# Get all data from WMI
if ($WMIOS -ne $null) { #if WMIOS is null - means connection failed. Abort script execution.
$WMICS = get-wmiobject -Class "win32_computersystem"
$WMIProcessor = get-wmiobject -Class "Win32_processor"
$OSProcessorArch = $WMIOS.OSArchitecture
$OSProcessorArchDisplay = " " + $OSProcessorArch
}
#There is no easy way to detect the OS Architecture on pre-Windows Vista Platform
if ($OSProcessorArch -eq $null)
{
if ($MachineName -eq ".") { #Local Computer
$OSProcessorArch = $Env:PROCESSOR_ARCHITECTURE
} else {
$RemoteReg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMachine",$MachineName)
$OSProcessorArch = ($RemoteReg.OpenSubKey("SYSTEM\CurrentControlSet\Control\Session Manager\Environment")).GetValue("PROCESSOR_ARCHITECTURE")
}
if ($OSProcessorArch -ne $null) {
switch ($OSProcessorArch) {
"AMD64" {$ProcessorArchDisplay = " (64-bit)"}
"i386" {$ProcessorArchDisplay = " (32-bit)"}
"IA64" {$ProcessorArchDisplay = " (64-bit - Itanium)"}
default {$ProcessorArchDisplay = " ($ProcessorArch)"}
}
} else {
$OSProcessorArchDisplay = ""
}
}
# Build OS Summary
# Name
add-member -inputobject $OS_Summary -membertype noteproperty -name "Machine Name" -value $WMIOS.CSName
add-member -inputobject $OS_Summary -membertype noteproperty -name "OS Name" -value ($WMIOS.Caption + " Service Pack " + $WMIOS.ServicePackMajorVersion + $OSProcessorArchDisplay)
add-member -inputobject $OS_Summary -membertype noteproperty -name "Build" -value ($WMIOS.Version)
add-member -inputobject $OS_Summary -membertype noteproperty -name "Time Zone/Offset" -value ((Get-WmiObject -Class Win32_TimeZone).Caption + "/" + $WMIOS.CurrentTimeZone)
# Install Date
#$date = [DateTime]::ParseExact($wmios.InstallDate.Substring(0, 8), "yyyyMdd", $null)
#add-member -inputobject $OS_Summary -membertype noteproperty -name "Install Date" -value $date.ToShortDateString()
add-member -inputobject $OS_Summary -membertype noteproperty -name "Last Reboot/Uptime" -value ($WMIOS.ConvertToDateTime($WMIOS.LastBootUpTime).ToString() + " (" + (GetAgeDescription(New-TimeSpan $WMIOS.ConvertToDateTime($WMIOS.LastBootUpTime))) + ")")
# Build Computer System Summary
# Name
add-member -inputobject $CS_Summary -membertype noteproperty -name "Computer Model" -value $WMICS.model
$numProcs=0
$ProcessorType = ""
$ProcessorName = ""
$ProcessorDisplayName= ""
foreach ($WMIProc in $WMIProcessor)
{
$ProcessorType = $WMIProc.manufacturer
switch ($WMIProc.NumberOfCores)
{
1 {$numberOfCores = "single core"}
2 {$numberOfCores = "dual core"}
4 {$numberOfCores = "quad core"}
$null {$numberOfCores = "single core"}
default { $numberOfCores = $WMIProc.NumberOfCores.ToString() + " core" }
}
switch ($WMIProc.Architecture)
{
0 {$CpuArchitecture = "x86"}
1 {$CpuArchitecture = "MIPS"}
2 {$CpuArchitecture = "Alpha"}
3 {$CpuArchitecture = "PowerPC"}
6 {$CpuArchitecture = "Itanium"}
9 {$CpuArchitecture = "x64"}
}
if ($ProcessorDisplayName.Length -eq 0)
{
$ProcessorDisplayName = " " + $numberOfCores + " $CpuArchitecture processor " + $WMIProc.name
} else {
if ($ProcessorName -ne $WMIProc.name)
{
$ProcessorDisplayName += "/ " + " " + $numberOfCores + " $CpuArchitecture processor " + $WMIProc.name
}
}
$numProcs += 1
$ProcessorName = $WMIProc.name
}
$ProcessorDisplayName = "$numProcs" + $ProcessorDisplayName
add-member -inputobject $CS_Summary -membertype noteproperty -name "Processor(s)" -value $ProcessorDisplayName
if ($WMICS.Domain -ne $null) {
add-member -inputobject $CS_Summary -membertype noteproperty -name "Machine Domain" -value $WMICS.Domain
}
if ($WMICS.DomainRole -ne $null) {
switch ($WMICS.DomainRole) {
0 {$RoleDisplay = "Workstation"}
1 {$RoleDisplay = "Member Workstation"}
2 {$RoleDisplay = "Standalone Server"}
3 {$RoleDisplay = "Member Server"}
4 {$RoleDisplay = "Backup Domain Controller"}
5 {$RoleDisplay = "Primary Domain controller"}
}
add-member -inputobject $CS_Summary -membertype noteproperty -name "Role" -value $RoleDisplay
}
if ($WMIOS.ProductType -eq 1) { #Client
$AntivirusProductWMI = get-wmiobject -query "select companyName, displayName, versionNumber, productUptoDate, onAccessScanningEnabled FROM AntivirusProduct" -Namespace "root\SecurityCenter"
if ($AntivirusProductWMI.displayName -ne $null) {
$AntivirusDisplay= $AntivirusProductWMI.companyName + " " + $AntivirusProductWMI.displayName + " version " + $AntivirusProductWMI.versionNumber
if ($AntivirusProductWMI.onAccessScanningEnabled) {
$AVScanEnabled = "Enabled"
} else {
$AVScanEnabled = "Disabled"
}
if ($AntivirusProductWMI.productUptoDate) {
$AVUpToDate = "Yes"
} else {
$AVUpToDate = "No"
}
#$AntivirusStatus = "OnAccess Scan: $AVScanEnabled" + ". Up to date: $AVUpToDate"
add-member -inputobject $OS_Summary -membertype noteproperty -name "Anti Malware" -value $AntivirusDisplay
} else {
$AntivirusProductWMI = get-wmiobject -Namespace root\SecurityCenter2 -Class AntiVirusProduct
if ($AntivirusProductWMI -ne $null) {
add-member -inputobject $OS_Summary -membertype noteproperty -name "AntiMalware" -value $AntivirusProductWMI.displayName
}
}
}
$SystemPolicies = get-itemproperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
$EnableLUA = $SystemPolicies.EnableLUA
$ConsentPromptBehaviorAdmin = $SystemPolicies.ConsentPromptBehaviorAdmin
if ($EnableLUA) {
$UACDisplay = "Enabled"
switch ($ConsentPromptBehaviorAdmin) {
0 {$UACDisplay += " / UAC Mode: ID_UACNoPrompt"}
1 {$UACDisplay += " / UAC Mode: ID_UACPromptCredentials"}
2 {$UACDisplay += " / UAC Mode: ID_UACPromptConsent"}
5 {$UACDisplay += " / UAC Mode: ID_UACPromptConsentApp"}
}
} else {
$UACDisplay = "Disabled"
}
add-member -inputobject $OS_Summary -membertype noteproperty -name "UAC" -value $UACDisplay
add-member -inputobject $OS_Summary -membertype noteproperty -name "Username" -value ($Env:USERDOMAIN + "\" + $Env:USERNAME)
# https://en.wikipedia.org/wiki/Windows_10_version_history
$versions = @{
"26100" = "Win11 24H2"
"22631" = "Win11 23H2"
"22622" = "Win11 22H2"
"22621" = "Win11 22H2"
"22000" = "Win11 21H2"
"19045" = "22H2"
"19044" = "21H2"
"19043" = "21H1"
"19042" = "20H2"
"19041" = "20H1"
"18363" = "1909"
"18362" = "1903"
"17763" = "1809"
"17134" = "1803"
"16299" = "1709"
"15063" = "1703"
"14393" = "1607"
"10586" = "1511"
"10240" = "RTM"
}
$marketingNames = @{
"26100" = "Win11 2024 Update"
"22631" = "Win11 2023 Update"
"22622" = "Win11 2022 Update"
"22621" = "Win11 2022 Update"
"22000" = "Win11 RTM"
"19045" = "Oct 2022 Update"
"19044" = "Nov 2021 Update"
"19043" = "May 2021 Update"
"19042" = "October 2020 Update"
"19041" = "May 2020 Update"
"18363" = "November 2019 Update"
"18362" = "May 2019 Update"
"17763" = "October 2018 Update"
"17134" = "April 2018 Update"
"16299" = "Fall Creators Update"
"15063" = "Creators Update"
"14393" = "Anniversary Update"
"10586" = "November Update"
"10240" = "RTM"
}
$codeNames = @{
"26100" = "Win11 24H2"
"22631" = "Win11 23H2"
"22622" = "Win11 22H2"
"22621" = "Win11 22H2"
"22000" = "Win11 21H2"
"19045" = "22H2"
"19044" = "21H2"
"19043" = "21H1"
"19042" = "20H2"
"19041" = "20H1"
"18363" = "19H2"
"18362" = "19H1"
"17763" = "Redstone 5"
"17134" = "Redstone 4"
"16299" = "Redstone 3"
"15063" = "Redstone 2"
"14393" = "Redstone 1"
"10586" = "Threshold 2"
"10240" = "Threshold 1"
}
$Win10Version = Get-WmiObject -Class Win32_OperatingSystem
#System Center Advisor Information
$SCAKey = "HKLM:\SOFTWARE\Microsoft\SystemCenterAdvisor"
if (Test-Path($SCAKey))
{
$CustomerID = (Get-ItemProperty -Path $SCAKey).CustomerID
if ($CustomerID -ne $null)
{
"System Center Advisor detected. Customer ID: $CustomerID" | writeto-stdout
$SCA_Summary = New-Object PSObject
$SCA_Summary | add-member -membertype noteproperty -name "Customer ID" -value $CustomerID
$SCA_Summary | ConvertTo-Xml2 | update-diagreport -id ("01_SCACustomerSummary") -name "System Center Advisor" -verbosity Informational
}
}
# Joined/Registered status
$ds = dsregcmd /status
[bool]$isRegistered = [bool]($ds -match "Work account")
[bool]$isJoined = [bool]($ds -match "AzureAdJoined : YES")
$Policies = "HKLM:\SOFTWARE\Microsoft\IntuneManagementExtension\Policies"
if (test-path $Policies) {
foreach ($Policy in (dir $Policies)) {
if ([guid]::Empty -ne $Policy.PSChildName) { $UserID = $Policy.PSChildName }
}
}
# Registered User and Tenant info
# Sort so we always get the most current in case there are orphaned certs
$cert = (dir Cert:\LocalMachine\My\ | where { $_.Issuer -match "CN=MS-Organization-Access" } )
if ($cert.count -gt 0) {
$cert = ($cert | Sort-Object -Property NotBefore -Descending)[0]
}
# use to find registry path
$thumbPrint = $cert.Thumbprint
# Get the tenant name from the registry
if (Test-Path HKLM:\SYSTEM\CurrentControlSet\Control\CloudDomainJoin\JoinInfo\$($thumbPrint)) {
$userEmail = (Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Control\CloudDomainJoin\JoinInfo\$($thumbPrint)).UserEmail
$tenant = $userEmail.Split('@')[1]
}
$MachineID = "Unknown"
$DeviceName = "Unknown"
$MachineIDContainer = dir HKLM:SOFTWARE\Microsoft\Enrollments -Recurse | Where {$_.Name -match 'MS DM Server'}
if ($MachineIDContainer){
$MachineID = $MachineIDContainer| Get-ItemPropertyValue -Name EntDMID
$DeviceName = $MachineIDContainer| Get-ItemPropertyValue -Name EntDeviceName
}
$SubscriptionID = $ds -match "SubscriptionID : (.+)"
# Start reporting
$highestWinBuildNumber = "26100"
$OS_Summary | Format-List
if ($Win10Version.BuildNumber -gt $highestWinBuildNumber) { "**** WARNING: Unknown version of Windows detected: Build $($Win10Version.version) *****"}
if ( (Get-CimInstance -ClassName Win32_OperatingSystem).OperatingSystemSKU -eq 125) {
"**** WARNING: Windows 10 OS is on the long-term servicing branch (LTSB) for updates. See https://aka.ms/IntuneLTSB for more information. *****"
}
"Windows build: $($Win10Version.version)"
"Windows version: $($versions[$Win10Version.BuildNumber])"
"Windows name: $($marketingNames[$Win10Version.BuildNumber])"
"Windows code name: $($codeNames[$Win10Version.BuildNumber])"
if ($isRegistered) {
"Azure AD status: Registered"
}
elseif ($isJoined) {
"Azure AD status: Joined"
}
else {
"Azure AD status: Not registered/joined or unknown"
}
$accountID = ""
$enrollmentID = ""
if (Test-Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\MDM) {
$accountID = (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\MDM).AccountId
}
if (Test-Path HKLM:\SOFTWARE\Microsoft\Provisioning\OMADM\Logger ) {
$enrollmentID = (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Provisioning\OMADM\Logger).CurrentEnrollmentId
}
if (Test-Path HKLM:SOFTWARE\Microsoft\Enrollments\$enrollmentID) {
$enrollmentKey = Get-ItemProperty "HKLM:SOFTWARE\Microsoft\Enrollments\$enrollmentID"
$AADTenantID = $enrollmentKey.AADTenantID
$contextID = ($enrollmentKey.CorrelationID) -replace "[\{\}]", ""
}
if ($UserID) { "Intune UserID: $UserID" }
if ($MachineID) { "Intune Device ID: $MachineID"}
if ($accountID) { "Intune Account ID: $accountID"}
if ($DeviceName) { "Intune Device Name: $DeviceName"}
if ($SubscriptionID) { "SubscriptionID: $SubscriptionID" }
if ($tenant) { "Tenant name: $tenant"}
if ($userEmail) { "User UPN: $userEmail"}
if ($AADTenantID) { "AAD Tenant ID: $AADTenantID"}
if ($contextID) { "Context ID: $contextID"}
$CS_Summary | Format-List
RunCommand systeminfo.exe
"BIOS Information"
RunCommand "Get-WmiObject -Class Win32_BIOS"
RunCommand Get-ComputerInfo
</Command>
<Command Type="PS" Team="General" OutputFileName="Installed_Products.txt">
$line = ("*" * 120) + "`r`n"
"$line Installed products list from Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall"
$line
Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Sort-Object DisplayName | Format-Table -Wrap -AutoSize
$line
Write-Output "Verbose"
$line
Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | format-list</Command>
<Command Type="CMD" Team="General" OutputFileName="proxy_settings.txt">netsh winhttp show proxy</Command>
<Command Type="PS" Team="General" OutputFileName="Bitlocker_and_TPM">
RunCommand "Get-Tpm"
RunCommand "Get-Tpm | Select-Object -ExpandProperty SelfTest"
RunCommand "tpmtool getdeviceinformation"
RunCommand "manage-bde -status"
RunCommand "Get-BitLockerVolume |fl * -Force"
RunCommand "Manage-bde -protectors -get $env:systemdrive"
RunCommand "Get-TpmEndorsementKeyInfo"
RunCommand "Get-TpmSupportedFeature -Verbose"
RunCommand "Get-CimInstance -ClassName Win32_Tpm -Namespace 'root\CIMV2\Security\MicrosoftTpm' "
RunCommand "Get-CimInstance -ClassName Win32_baseboard -Namespace 'root\CIMV2' "
RunCommand "reagentc /info"
RunCommand "bcdedit /enum all"
RunCommand "gwmi win32_bios | fl *"
RunCommand "Get-Service tpm |fl *"
RunCommand "powercfg /a"
# put TPM logs output in files\bitlocker
$outputPath = "$env:temp\CollectedData\Intune\Files\Bitlocker"
$x = if (-not (Test-Path $outputPath)) { mkdir $outputPath -Force}
$x = &tpmtool gatherlogs "$outputPath"
# Registry keys
$BLKeys = @(
"HKLM:\SOFTWARE\Microsoft\PolicyManager\current\device\BitLocker",
"HKLM:\SOFTWARE\Microsoft\PolicyManager\default\Bitlocker",
"HKLM:\SOFTWARE\Policies\Microsoft\FVE"
)
foreach ($BLKey in $BLKeys) {
if (Test-Path $BLKey) {
Get-PrintableRegKeyValues $BLKey
}
else {
Write-Output "$BLKey not found"
}
}
Get-ChildItem HKLM:\SOFTWARE\Microsoft\PolicyManager\Providers\*\Bitlocker -Recurse
# Disk config
RunCommand "Get-Disk | fl *"
RunCommand "gwmi Win32_DiskPartition"
RunCommand "gwmi -class win32_logicaldisk"
RunCommand "gwmi -class win32_volume"</Command>
<Command Type="PS" Team="General" OutputFileName="Firewall_Settings">RunCommand "netsh advfirewall show allprofiles"
RunCommand "netsh advfirewall show allprofiles"
RunCommand "netsh advfirewall show global"
RunCommand "Get-NetFirewallProfile"
RunCommand "Get-NetFirewallRule"
RunCommand "Get-NetFirewallSetting"</Command>
<Command Type="PS" Team="AV" OutputFileName="Get-MpComputerStatus.txt">
RunCommand "Get-MpComputerStatus"
</Command>
<Command Type="PS" Team="General" OutputFileName="NA">#Gather Defender files
$mpc = "$env:ProgramFiles\Windows Defender\MpCmdRun.exe"
$outputPath = "$env:temp\CollectedData\Intune\Commands\AV"
$x = if (-not (Test-Path $outputPath)) { mkdir $outputPath -Force}
$mpcExists = Test-Path -Path $mpc
$DefenderServiceIsRunning = (Get-Service sense).Status
$WinDefendServiceIsRunning = (Get-Service windefend).Status
if ($mpcExists -and ($DefenderServiceIsRunning -eq "Running" )) {
RunCommand Get-MpComputerStatus -Verbose
RunCommand Get-MpPreference -Verbose
RunCommand Get-MpThreatDetection
$output = &$mpc -getfiles
# Get the full path to the cab
$cabPath = $output -match "MpSupportFiles.cab"
$cabPath = $cabPath -replace "^.* *(.:.*)", "`$1"
copy $cabPath $outPutPath\WindowsDefender-SupportFiles.cab
}
else {
$deflog = join-path $outputPath "DefenderErrors.txt"
"Warning: Defender Service (sense) is not running. Startup type is $DefenderStartupType. This is expected if 3rd party AV is installed. Skipping Defender data collection." | Out-File $deflog -Force
"Defender service (sense) status is $DefenderServiceIsRunning" | Out-File $deflog -Append -Force
"Defender service (windefend) status is $WinDefendServiceIsRunning" | Out-File $deflog -Append -Force
"Defender executable exists at $mpc is $mpcExists" | Out-File $deflog -Append -Force
}
</Command>
<Command Type="PS" Team="Networking" OutputFileName="Networking.txt">RunCommand -cmdToRun "hostname"
RunCommand -cmdToRun "ipconfig /all"
RunCommand -cmdToRun "arp -a"
RunCommand -cmdToRun "nbtstat -n"
RunCommand -cmdToRun "netstat -ano"
RunCommand -cmdToRun "netstat -anob"
RunCommand -cmdToRun "reg.exe query HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters /v EnableTCPChimney"
RunCommand -cmdToRun "reg.exe query HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters /v EnableRSS"
RunCommand -cmdToRun "reg.exe query HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters /v EnableTCPA"
RunCommand -cmdToRun "reg.exe query HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters /v DisableTaskOffload"
if ($OSVersion.Major -ge 6)
{
RunCommand -cmdToRun "netsh int tcp show global"
RunCommand -cmdToRun "netsh int ipv4 show offload"
RunCommand -cmdToRun "netstat -nato -p tcp" -FileDescription "TCP/IP Basic Information" -CollectFile $true
}
else
{
RunCommand -cmdToRun "netstat -ano -p tcp"
}
RunCommand -cmdToRun "net config workstation"
if ((Get-Service "lanmanserver").Status -eq 'Running')
{
RunCommand -cmdToRun "net config server"
RunCommand -cmdToRun "net share"
}
RunCommand -cmdToRun "net sessions"
RunCommand -cmdToRun "net use"
RunCommand -cmdToRun "net user"
RunCommand -cmdToRun "net accounts"
RunCommand -cmdToRun "net statistics workstation"</Command>
<Command Type="PS" Team="General" OutputFileName="sym_Process.txt">Get-Process | select Name, FileVersion, Path, ProductVersion | ft -auto -wrap</Command>
<Command Type="PS" Team="General" OutputFileName="sym_drivers.txt">Get-WmiObject Win32_PnPSignedDriver| select DeviceName, DriverVersion | ft -auto -wrap</Command>
<Command Type="PS" Team="General" OutputFileName="sym_RunningDrivers.txt">Get-WmiObject Win32_PnPSignedDriver | select DeviceName, DriverVersion | ft -auto</Command>
<Command Type="CMD" Team="General" OutputFileName="ScheduledTasks">schtasks.exe /fo list /v</Command>
<Command Type="PS" Team="General" OutputFileName="NA">$outputPath = "$env:temp\CollectedData\Intune\Commands\Windows Update"
$x = if (-not (Test-Path $outputPath)) { mkdir $outputPath -Force}
Get-WindowsUpdateLog -Logpath $outputPath\$($env:COMPUTERNAME)_WindowsUpdate.log</Command>
<Command Type="CMD" Team="General" OutputFileName="GPResult.txt">gpresult.exe /V</Command>
<Command Type="PS" Team="General" OutputFileName="InstalledWindowsFeatures">Get-WindowsOptionalFeature -Online | where {$_.State -eq "Enabled"}</Command>
<Command Type="PS" Team="Networking" OutputFileName="NetSH_Commands">echo "======= netsh int show int ======"
netsh int show int
echo "======= netsh int ipv4 show int ======"
netsh int ipv4 show int
echo "======= netsh int ipv4 show addresses ======"
netsh int ipv4 show addresses
echo "======= netsh int ipv4 show ipaddresses ======"
netsh int ipv4 show ipaddresses
echo "======= netsh int ipv4 show compartments ======"
netsh int ipv4 show compartments
echo "======= netsh int ipv4 show dnsservers ======"
netsh int ipv4 show dnsservers
echo "======= netsh int ipv4 show winsservers ======"
netsh int ipv4 show winsservers
echo "======= netsh int ipv4 show dynamicportrange tcp ======"
netsh int ipv4 show dynamicportrange tcp
echo "======= netsh int ipv4 show dynamicportrange udp ======"
netsh int ipv4 show dynamicportrange udp
echo "======= netsh int ipv4 show global ======"
netsh int ipv4 show global
echo "======= netsh int ipv4 show icmpstats ======"
netsh int ipv4 show icmpstats
echo "======= netsh int ipv4 show ipstats ======"
netsh int ipv4 show ipstats
echo "======= netsh int ipv4 show joins ======"
netsh int ipv4 show joins
echo "======= netsh int ipv4 show offload ======"
netsh int ipv4 show offload
echo "======= netsh int ipv4 show route ======"
netsh int ipv4 show route
echo "======= netsh int ipv4 show subint ======"
netsh int ipv4 show subint
echo "======= netsh int ipv4 show tcpconnections ======"
netsh int ipv4 show tcpconnections
echo "======= netsh int ipv4 show tcpstats ======"
netsh int ipv4 show tcpstats
echo "======= netsh int ipv4 show udpconnections ======"
netsh int ipv4 show udpconnections
echo "======= netsh int ipv4 show udpstats ======"
netsh int ipv4 show udpstats
echo "======= netsh int ipv4 show destinationcache ======"
netsh int ipv4 show destinationcache
echo "======= netsh int ipv4 show ipnettomedia ======"
netsh int ipv4 show ipnettomedia
echo "======= netsh int ipv4 show neighbors ======"
netsh int ipv4 show neighbors
</Command>
<Command Type="PS" Team="Networking" OutputFileName="Connectivity_tests">
$uniqueURLs = @()
$uniqueURLs += (dsregcmd /status) | ForEach-Object { if ($_ -match ".*https://(\w+.+?)\/") { $matches[1]} } | Get-Unique
$uniqueURLs += "r.manage.microsoft.com"
$uniqueURLs += "r.manage.microsoft.us"
$uniqueURLs += "enterpriseregistration.windows.net"
$ErrorActionPreference = "Stop"
foreach($uniqueURL in $uniqueURLs) {
if ($uniqueURL -match "(.*):(\d+)") {
$port = $Matches[2]
$uniqueURL = $Matches[1]
}
else {
$port = "443"
}
try {
$error.Clear()
$connectionTest = $false
$connection = New-Object System.Net.Sockets.TCPClient
$connection.ReceiveTimeout = [int32]500
$connection.SendTimeout = [int32]500
$x = ($connection.ConnectAsync( $uniqueURL, $port)).Wait(5000)
$connectionTest = $connection.Connected
}
catch {
Write-Output "Error connecting to $uniqueURL`: $error"
}
finally {
"{0, -72} : {1,6}" -f "Able to connect to port $port on $uniqueURL", $connectionTest | Write-Output
}
}
</Command>
<Command Type="PS" Team="Networking" OutputFileName="DNS_Tests.txt">
$DNSCommands = @("Get-DnsClient", "Get-DnsClientCache", "Get-DnsClientDohServerAddress", "Get-DnsClientGlobalSetting", "Get-DnsClientNrptGlobal", "Get-DnsClientNrptPolicy", "Get-DnsClientNrptRule", "Get-DnsClientServerAddress" )
foreach ($DNSCommand in $DNSCommands) {
RunCommand $DNSCommand
}
</Command>
<Command Type="PS" Team="General" OutputFileName="TimeZoneSettings">w32tm /tz</Command>
<Command Type="PS" Team="NDES" OutputFileName="NA">#NDES
function Get-FilesOlderThan
{
Param ([int]$days = 2,
[string]$path = $pwd
)
$DaysAgo = (Get-Date).AddDays(-($days))
$files = @()
$files = Get-ChildItem $path | where { $_.CreationTime -gt $DaysAgo }
# get latest file if none meet our criteria
if ((Test-Path $path) -and (-not $files) ) {
$newestFile = Get-ChildItem $path |Sort-Object LastAccessTime -Descending | Select-Object -First 1
$files += $newestFile
}
$files
}
if (Test-Path HKLM:\SOFTWARE\Microsoft\MicrosoftIntune\NDESConnector) {
$installFolder = (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\MicrosoftIntune\NDESConnector).InstallFolder
$copyPath = "$env:temp\CollectedData\Intune\Files\NDES"
if ($installFolder) {
$ndesPaths = @(
"$installFolder\NDESPolicyModule\Logs\NDESPlugin.log",
"$installFolder\NDESConnectorSvc\Logs\Logs\NDESConnector*",
"$installFolder\NDESConnectorSvc\Logs\Logs\CertificateRegistrationPoint*",
"$installFolder\NDESConnectorUI\NDESConnectorUI.log",
"$installFolder\NDESConnectorUI\Logs\*",
"C:\inetpub\logs\LogFiles\W3SVC1\u_ex*.log"
"$installFolder\NDESPolicyModule\Logs\NDESPlugin.log",
"C:\NDESConnectorSetup\*.log",
"$env:programfiles\Microsoft Configuration Manager\logs\ndes*"
)
if (-not(test-path $copyPath) ) { $x = mkdir $copyPath -Force }
ForEach ($ndesPath in $ndesPaths) {
if (Test-Path $ndesPath) {
$filesToCollect = Get-FilesOlderThan -path $ndesPath -days 3
foreach ($fileToCollect in $filesToCollect) { copy $fileToCollect $copyPath}
}
}
copy "C:\NDESConnectorSetupMSI\*" $copyPath
}
}
</Command>
<Command Type="PS" Team="NDES" OutputFileName="certificate_authority.txt">certutil.exe</Command>
<Command Type="PS" Team="Configmgr" OutputFileName="NA">#ConfigMgr
if (Test-Path HKLM:\SOFTWARE\Microsoft\CCM\Logging\@Global) {
$ccmFolder = (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\CCM\Logging\@Global).LogDirectory
$copyPath = "$env:temp\CollectedData\Intune\Files\ConfigMgr"
if ($ccmFolder) {
if (-not(test-path $copyPath) ) { $x = mkdir $copyPath -Force }
$filesToCollect = Get-ChildItem -Path $ccmFolder
foreach ($fileToCollect in $filesToCollect) { copy $fileToCollect.PSPath $copyPath}
}
}
else {
"CCM folder not found. Exiting."
}</Command>
<Command Type="PS" Team="NDES" OutputFileName="Certificate_templates.txt">RunCommand -cmdToRun "certutil -v -template"
if (Test-Path HKLM:\SOFTWARE\Microsoft\Cryptography\MSCEP\CAInfo) {
$config = (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Cryptography\MSCEP\CAInfo).Configuration
RunCommand -cmdToRun "certutil -CATemplates -config $config"
}
</Command>
<Command Type="PS" Team="NDES" OutputFileName="Validate-NDES-Output.txt">
$ndesScript = @'
# cut here
<#
.SYNOPSIS
Highlights configuration problems on an NDES server, as configured for use with Intune Standalone SCEP certificates.
.DESCRIPTION
Validate-NDESConfig looks at the configuration of your NDES server and ensures it aligns to the "Configure and manage SCEP
certificates with Intune" article.
.NOTE This script is used purely to validate the configuration. All remedial tasks will need to be carried out manually.
Where possible, a link and section description will be provided.
.EXAMPLE
.\Validate-NDESConfiguration -NDESServiceAccount Contoso\NDES_SVC.com -IssuingCAServerFQDN IssuingCA.contoso.com -SCEPUserCertTemplate SCEPGeneral
.EXAMPLE
.\Validate-NDESConfiguration -help
.LINK
https://docs.microsoft.com/en-us/intune/certificates-scep-configure#configure-your-infrastructure
#>
[CmdletBinding(DefaultParameterSetName="Unattended")]
Param(
[parameter(Mandatory=$false,ParameterSetName="Unattended")]
[alias("ua","silent","s","unattended")]
[switch]$unattend,
[parameter(Mandatory=$true,ParameterSetName="NormalRun")]
[alias("sa")]
[ValidateScript({
if ($_ -match ".\\.") {
$True
}
else {
Throw "Please use the format Domain\Username for the NDES Service Account variable."
}
$EnteredDomain = $_.split("\")
$ads = New-Object -ComObject ADSystemInfo
$Domain = $ads.GetType().InvokeMember('DomainShortName','GetProperty', $Null, $ads, $Null)
if ($EnteredDomain -like "$Domain") {
$True
}