forked from gordonrankine/get-win10info
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGet-Win10Info.ps1
9017 lines (7654 loc) · 373 KB
/
Get-Win10Info.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
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
#region ScriptInfo
<#
.SYNOPSIS
Gets Windows 10 Operating System details from a computer and generated a word document with the information gathered.
.DESCRIPTION
Gets Windows 10 Operating System details from a computer and generated a word document with the information gathered. This script has various modes, GatherAndReport, GatherOnly & ReportOnly
each can be used for different purposes. The report can either be basic or detailed. This script can run against a report endpoint. See examples for futher detials.
.PARAMETER outDir
This is the directory where the xml files and reports are stored. If the directory doesn't exist it will be created.
.PARAMETER mode
[OPTIONAL] This is the mode the script runs in. There are 3 modes available. GatherAndReport, GatherOnly & ReportOnly. GatherAndReport will collect details and generate a word document. GatherOnly will collect
details only. ReportOnly will construct a word document from a provided xml file with previously gathered details. The default mode is GatherAndReport.
.PARAMETER endpoint
[OPTIONAL] This is the name of the remote endpoint if the script is to gather information from a remote endpoint. If this parameter is not specified then the script will run against the endpoint
that the script is running on.
.PARAMETER xmlReport
[OPTIONAL] This parameter is only used for ReportOnly mode and is the xml file with the details previously gathered using GatherAndReport or GatherOnly mode.
.PARAMETER reportMode
[OPTIONAL] This is the report mode of the script. It can either be Basic or Detailed. Basic will report a smaller set of data whilst Detailed will provide a greater level of report.
.EXAMPLE
.\Get-Win10Info.ps1 -outDir "c:\temp"
Runs the script in GatherAndReport mode which will save a basic report to c:\temp
.EXAMPLE
.\Get-Win10Info.ps1 -outDir "c:\temp" -endpoint PC01
Runs the script in GatherAndReport mode which will save a basic report to c:\temp with the details gather from the remote endpoint PC01.
.\Get-Win10Info.ps1 -outDir "c:\temp" -mode GatherOnly -endpoint PC01
Runs the script in GatherOnly and collects details from the remote endpoint PC01.
.\Get-Win10Info.ps1 -outDir "c:\temp" -mode ReportOnly -xmlFile c:\temp\PC01_201909291709.xml -ReportType Detailed
Runs the script in ReportOnly mode and generates a detailed report using PC01_201909291709.xml.
.LINK
https://github.com/gordonrankine/get-win10info
.NOTES
License: MIT License
Compatibility: Windows 10
Author: Gordon Rankine
Date: 12/05/2021
Version: 1.4
PSScriptAnalyzer: Pass (with caveat). Run ScriptAnalyzer with PSAvoidUsingWMICmdlet. WMI over CIM as WMI is more versatile than CIM.
Change Log: Version Date Author Comments
1.0 29/09/2019 Gordon Rankine Initial script
1.1 31/10/2020 Gordon Rankine Added Window System Assessment Tool (win32_winsat). Added blank lines to either side of script complete message.
1.2 21/11/2020 Gordon Rankine Added Computer Certificates (System.Security.Cryptography.X509Certificates.X509Store).
1.3 28/04/2021 Gordon Rankine Added Power Plan (win32_powerplan).
1.4 12/05/2021 Gordon Rankine Added Software Licensing Product (softwarelicensingproduct). Fixed operatingsystem.operatingsystemsku error, 450 changed to 45 and added 48 (was missing).
#>
#endregion ScriptInfo
#region Bindings
[cmdletbinding()]
Param(
[Parameter(Mandatory=$True, Position=1, HelpMessage="This is the directory for the output file.")]
[string]$outDir,
[Parameter(Mandatory=$False, Position=2, HelpMessage="This is the mode that the script will run in. There are 3 modes: GatherAndReport, GatherOnly and ReportOnly. GatherAndReport is the default option.")]
[ValidateSet('GatherAndReport','GatherOnly','ReportOnly')]
[string]$mode = 'GatherAndReport',
[Parameter(Mandatory=$False, Position=3, HelpMessage="This is the hostname of the endpoint that the data is to be collected from. If no endpoint is selected, the script will default to the local computer.")]
[string]$endpoint = $env:COMPUTERNAME,
[Parameter(Mandatory=$False, Position=4, HelpMessage="This is the xml report generated from either the GatherAndReport or GatherOnly modes.")]
[string]$xmlReport,
[Parameter(Mandatory=$False, Position=5, HelpMessage="This is the type of report to run. There are 2 reports: Basic or Detailed. Basic is the default report type.")]
[ValidateSet('Basic','Detailed')]
[string]$reportType = 'Basic'
)
#endregion Bindings
#region Functions
### START FUNCTIONS ###
### FUNCTION - CREATE DIRECTORY ###
function fnCreateDir {
<#
.SYNOPSIS
Creates a directory.
.DESCRIPTION
Creates a directory.
.PARAMETER outDir
This is the directory to be created.
.EXAMPLE
.\Create-Directory.ps1 -outDir "c:\test"
Creates a directory called "test" in c:\
.EXAMPLE
.\Create-Directory.ps1 -outDir "\\COMP01\c$\test"
Creates a directory called "test" in c:\ on COMP01
.LINK
https://github.com/gordonrankine/powershell
.NOTES
License: MIT License
Compatibility: Windows 7 or Server 2008 and higher
Author: Gordon Rankine
Date: 13/01/2019
Version: 1.1
PSSscriptAnalyzer: Pass
#>
[CmdletBinding()]
Param(
# The directory to be created.
[Parameter(Mandatory=$True, Position=0, HelpMessage='This is the directory to be created. E.g. C:\Temp')]
[string]$outDir
)
# Create out directory if it doesnt exist
if(!(Test-Path -path $outDir)){
if(($outDir -notlike "*:\*") -and ($outDir -notlike "*\\*")){
Write-Output "[ERROR]: $outDir is not a valid path. Script terminated."
break
}
try{
New-Item $outDir -type directory -Force -ErrorAction Stop | Out-Null
Write-Output "[INFO] Created output directory $outDir"
}
catch{
Write-Output "[ERROR]: There was an issue creating $outDir. Script terminated."
Write-Output ($_.Exception.Message)
Write-Output ""
break
}
}
# Directory already exists
else{
Write-Output "[INFO] $outDir already exists."
}
} # end fnCreateDir
### FUNCTION - CHECK POWERSHELL IS RUNNING AS ADMINISTRATOR ###
function fnCheckPSAdmin {
<#
.SYNOPSIS
Checks PowerShell is running as Administrator.
.DESCRIPTION
Checks PowerShell is running as Administrator.
.LINK
https://github.com/gordonrankine/powershell
.NOTES
License: MIT License
Compatibility: Windows 7 or Server 2008 and higher
Author: Gordon Rankine
Date: 19/09/2019
Version: 1.0
PSSscriptAnalyzer: Pass
#>
try{
$wIdCurrent = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$wPrinCurrent = New-Object System.Security.Principal.WindowsPrincipal($wIdCurrent)
$wBdminRole = [System.Security.Principal.WindowsBuiltInRole]::Administrator
if(!$wPrinCurrent.IsInRole($wBdminRole)){
Write-Output "[ERROR] PowerShell is not running as administrator. Script terminated."
Break
}
}
catch{
Write-Output "[ERROR] There was an unexpected error checking if PowerShell is running as administrator. Script terminated."
Break
}
} # end fnCheckPSAdmin
#endregion Functions ### END FUNCTIONS ###
#region Initialize
Clear-Host
# Start stopwatch
$sw = [system.diagnostics.stopwatch]::StartNew()
fnCheckPSAdmin
fnCreateDir $outDir
$date = Get-Date -UFormat %Y%m%d%H%M #%d-%m-%Y-%H%M
$outFile = "$outDir\$endpoint`_$date.xml"
$warnings = 0
$tab = "`t"
# Validate correct parameters used for ReportOnly mode
if(($mode -eq "ReportOnly") -and ($xmlReport -eq "")){
Write-Output "[ERROR] ReportOnly mode needs the xml file. Please use -xmlReport parameter when running this mode."
break
}
# Validate correct parameters used for GatherAndReport mode
if(($mode -eq "GatherAndReport") -and ($xmlReport -ne "")){
Write-Output "[ERROR] GatherAndReport mode should not have the xml file specified. If you have not specified -mode GatherAndReport explicitly, remember this is the default mode. Please remove -xmlReport parameter when running this mode."
break
}
Write-Output "[INFO] Script running in $mode mode."
if(($mode -eq "GatherAndReport") -or ($mode -eq "GatherOnly")){
$reportFile = $outFile
}
else{
$reportFile = $xmlReport
}
if($mode -ne "ReportOnly"){
# Check that content can be written to outfile
try{
Write-Output "[INFO] XML capture file is $outDir\$endpoint`_$date.xml."
Add-Content $outfile "<?xml version=`"1.0`" encoding=`"UTF-8`"?>" -ErrorAction SilentlyContinue
}
catch{
Write-Output "[ERROR] There was an unexpected error while writing the xml file. Script terminated."
Write-Output "[ERROR] $($_.Exception.Message)."
break
}
#endregion Initialize
#region Gather
#region GatherGeneral
Add-Content $outfile "<info>"
Add-Content $outfile "$tab<general>"
Add-Content $outfile "$tab$tab<ge_server>$endpoint</ge_server>"
Add-Content $outfile "$tab$tab<ge_inventdate>$date</ge_inventdate>"
Add-Content $outfile "$tab$tab<ge_scriptname>$($myInvocation.MyCommand.Name)</ge_scriptname>"
Add-Content $outfile "$tab$tab<ge_runby>$($env:USERDOMAIN + "\" + $env:USERNAME)</ge_runby>"
if($env:COMPUTERNAME -eq $endpoint){
$remote = "No"
}
else{
$remote = "Yes"
}
Add-Content $outfile "$tab$tab<ge_remote>$($remote)</ge_remote>"
Add-Content $outfile "$tab</general>"
#endregion GatherGeneral
#region GatherRegistryOperatingSystem
try{
Write-Output "[INFO] Getting Operating System details from registry."
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $endpoint)
$key = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"
$openSubKey = $reg.OpenSubKey($key)
Add-Content $outfile "$tab<winver>"
Add-Content $outfile "$tab$tab<version>$($openSubKey.getvalue("ReleaseId"))</version>"
Add-Content $outfile "$tab$tab<build>$($openSubKey.getvalue("CurrentBuild") + "." + $openSubKey.getvalue("UBR"))</build>"
Add-Content $outfile "$tab$tab<buildbranch>$($openSubKey.getvalue("BuildBranch"))</buildbranch>"
Add-Content $outfile "$tab$tab<editionid>$($openSubKey.getvalue("EditionId"))</editionid>"
Add-Content $outfile "$tab$tab<productname>$($openSubKey.getvalue("ProductName"))</productname>"
Add-Content $outfile "$tab$tab<registeredorganization>$($openSubKey.getvalue("RegisteredOrganization"))</registeredorganization>"
Add-Content $outfile "$tab$tab<registeredowner>$($openSubKey.getvalue("RegisteredOwner"))</registeredowner>"
Add-Content $outfile "$tab</winver>"
}
catch{
Add-Content $outfile "$tab<winver>"
Add-Content $outfile "$tab$tab<errorcode>1</errorcode>"
Add-Content $outfile "$tab$tab<errortext>$_.Exception.Message</errortext>"
Add-Content $outfile "$tab</winver>"
Write-Output "[WARNING] There was an unexpected error while getting the winver details. Moving on to next section..."
$warnings ++
}
#endregion GatherRegistryOperatingSystem
#region GatherWMIOperatingSystem
$class = "win32_operatingsystem" # Single item class
try{
Write-Output "[INFO] Getting details from class $class."
$props = ('buildnumber', 'caption', 'csname', 'encryptionlevel', 'installdate', 'operatingsystemsku', 'osarchitecture', 'osproductsuite', 'producttype', 'servicepackmajorversion', 'servicepackminorversion', 'totalvisiblememorysize', 'version')
$wmi = Get-WmiObject -Namespace root/cimv2 -Class $class -ComputerName $endpoint -ErrorAction Stop | Select-Object $props
Add-Content $outfile "$tab<$class>"
foreach($prop in $props){
Add-Content $outfile "$tab$tab<$prop>$($wmi.$prop)</$prop>"
}
Add-Content $outfile "$tab</$class>"
}
catch{
Add-Content $outfile "$tab<$class>"
Add-Content $outfile "$tab$tab<errorcode>1</errorcode>"
Add-Content $outfile "$tab$tab<errortext>$_.Exception.Message</errortext>"
Add-Content $outfile "$tab</$class>"
Write-Output "[WARNING] There was an unexpected error while getting the $class class. Moving on to next section..."
$warnings ++
}
#endregion GatherWMIOperatingSystem
#region GatherWMIComputerSystem
$class = "win32_computersystem" # Single item class
try{
Write-Output "[INFO] Getting details from class $class."
$props = ('adminpasswordstatus', 'name', 'domain', 'domainrole', 'manufacturer', 'model', 'numberoflogicalprocessors', 'partofdomain', 'roles', 'systemtype', 'totalphysicalmemory', 'wakeuptype')
$wmi = Get-WmiObject -Namespace root/cimv2 -Class $class -ComputerName $endpoint -ErrorAction Stop | Select-Object $props
Add-Content $outfile "$tab<$class>"
foreach($prop in $props){
Add-Content $outfile "$tab$tab<$prop>$($wmi.$prop)</$prop>"
}
Add-Content $outfile "$tab</$class>"
}
catch{
Add-Content $outfile "$tab<$class>"
Add-Content $outfile "$tab$tab<errorcode>1</errorcode>"
Add-Content $outfile "$tab$tab<errortext>$_.Exception.Message</errortext>"
Add-Content $outfile "$tab</$class>"
Write-Output "[WARNING] There was an unexpected error while getting the $class class. Moving on to next section..."
$warnings ++
}
#endregion GatherWMIComputerSystem
#region GatherWMIWinSat
$class = "win32_winsat" # Single item class
try{
Write-Output "[INFO] Getting details from class $class."
$props = ('cpuscore', 'd3dscore', 'diskscore', 'graphicsscore', 'memoryscore', 'timetaken', 'winsatassessmentstate', 'winsprlevel')
$wmi = Get-WmiObject -Namespace root/cimv2 -Class $class -ComputerName $endpoint -ErrorAction Stop | Select-Object $props
Add-Content $outfile "$tab<$class>"
foreach($prop in $props){
Add-Content $outfile "$tab$tab<$prop>$($wmi.$prop)</$prop>"
}
Add-Content $outfile "$tab</$class>"
}
catch{
Add-Content $outfile "$tab<$class>"
Add-Content $outfile "$tab$tab<errorcode>1</errorcode>"
Add-Content $outfile "$tab$tab<errortext>$_.Exception.Message</errortext>"
Add-Content $outfile "$tab</$class>"
Write-Output "[WARNING] There was an unexpected error while getting the $class class. Moving on to next section..."
$warnings ++
}
#endregion GatherWMIWinSat
#region GatherWMINetworkAdapterConfiguration
$class = "win32_networkadapterconfiguration" # Multi item class
try{
Write-Output "[INFO] Getting details from class $class."
$props = ('dhcpleaseexpires', 'description', 'dhcpenabled', 'dhcpleaseobtained', 'dhcpserver', 'dnsdomain', 'dnsdomainsuffixsearchorder' ,'dnsenabledforwinsresolution', 'dnshostname', 'dnsserversearchorder', 'ipaddress', 'ipenabled', 'ipfiltersecurityenabled', 'winsenablelmhostslookup', 'winsprimaryserver', 'winssecondaryserver', 'caption', 'defaultipgateway', 'ipsubnet', 'macaddress')
$wmi = Get-WmiObject -Namespace root/cimv2 -Class $class -Filter "IPEnabled = 'True'" -ComputerName $endpoint -ErrorAction Stop | Select-Object $props | Sort-Object description
Add-Content $outfile "$tab<$class>"
foreach($wm in $wmi){
Add-Content $outfile "$tab$tab<$class`_multi>"
Add-Content $outfile "$tab$tab$tab<dhcpleaseexpires>$($wm.dhcpleaseexpires)</dhcpleaseexpires>"
Add-Content $outfile "$tab$tab$tab<description>$($wm.description)</description>"
Add-Content $outfile "$tab$tab$tab<dhcpenabled>$($wm.dhcpenabled)</dhcpenabled>"
Add-Content $outfile "$tab$tab$tab<dhcpleaseobtained>$($wm.dhcpleaseobtained)</dhcpleaseobtained>"
Add-Content $outfile "$tab$tab$tab<dhcpserver>$($wm.dhcpserver)</dhcpserver>"
Add-Content $outfile "$tab$tab$tab<dnsdomain>$($wm.dnsdomain)</dnsdomain>"
Add-Content $outfile "$tab$tab$tab<dnsdomainsuffixsearchorder>$($wm.dnsdomainsuffixsearchorder)</dnsdomainsuffixsearchorder>"
Add-Content $outfile "$tab$tab$tab<dnsenabledforwinsresolution>$($wm.dnsenabledforwinsresolution)</dnsenabledforwinsresolution>"
Add-Content $outfile "$tab$tab$tab<dnshostname>$($wm.dnshostname)</dnshostname>"
Add-Content $outfile "$tab$tab$tab<dnsserversearchorder>$($wm.dnsserversearchorder)</dnsserversearchorder>"
Add-Content $outfile "$tab$tab$tab<ipaddress>$($wm.ipaddress)</ipaddress>"
Add-Content $outfile "$tab$tab$tab<ipenabled>$($wm.ipenabled)</ipenabled>"
Add-Content $outfile "$tab$tab$tab<ipfiltersecurityenabled>$($wm.ipfiltersecurityenabled)</ipfiltersecurityenabled>"
Add-Content $outfile "$tab$tab$tab<winsenablelmhostslookup>$($wm.winsenablelmhostslookup)</winsenablelmhostslookup>"
Add-Content $outfile "$tab$tab$tab<winsprimaryserver>$($wm.winsprimaryserver)</winsprimaryserver>"
Add-Content $outfile "$tab$tab$tab<winssecondaryserver>$($wm.winssecondaryserver)</winssecondaryserver>"
Add-Content $outfile "$tab$tab$tab<caption>$($wm.caption)</caption>"
Add-Content $outfile "$tab$tab$tab<defaultipgateway>$($wm.defaultipgateway)</defaultipgateway>"
Add-Content $outfile "$tab$tab$tab<ipsubnet>$($wm.ipsubnet)</ipsubnet>"
Add-Content $outfile "$tab$tab$tab<macaddress>$($wm.macaddress)</macaddress>"
Add-Content $outfile "$tab$tab</$class`_multi>"
}
Add-Content $outfile "$tab</$class>"
}
catch{
Add-Content $outfile "$tab<$class>"
Add-Content $outfile "$tab$tab<errorcode>1</errorcode>"
Add-Content $outfile "$tab$tab<errortext>$_.Exception.Message</errortext>"
Add-Content $outfile "$tab</$class>"
Write-Output "[WARNING] There was an unexpected error while getting the $class class. Moving on to next section..."
$warnings ++
}
#endregion GatherWMINetworkAdapterConfiguration
#region GatherWMIPhysicalMemory
$class = "win32_physicalmemory" # Multi item class
try{
Write-Output "[INFO] Getting details from class $class."
$props = ('capacity', 'configuredclockspeed', 'datawidth', 'devicelocator', 'formfactor', 'manufacturer', 'memorytype', 'model', 'partnumber', 'serialnumber', 'speed')
$wmi = Get-WmiObject -Namespace root/cimv2 -Class $class -ComputerName $endpoint -ErrorAction Stop | Select-Object $props | Sort-Object devicelocator
Add-Content $outfile "$tab<$class>"
foreach($wm in $wmi){
Add-Content $outfile "$tab$tab<$class`_multi>"
Add-Content $outfile "$tab$tab$tab<capacity>$($wm.capacity)</capacity>"
Add-Content $outfile "$tab$tab$tab<configuredclockspeed>$($wm.configuredclockspeed)</configuredclockspeed>"
Add-Content $outfile "$tab$tab$tab<datawidth>$($wm.datawidth)</datawidth>"
Add-Content $outfile "$tab$tab$tab<devicelocator>$($wm.devicelocator)</devicelocator>"
Add-Content $outfile "$tab$tab$tab<formfactor>$($wm.formfactor)</formfactor>"
Add-Content $outfile "$tab$tab$tab<manufacturer>$($wm.manufacturer)</manufacturer>"
Add-Content $outfile "$tab$tab$tab<memorytype>$($wm.memorytype)</memorytype>"
Add-Content $outfile "$tab$tab$tab<model>$($wm.model)</model>"
Add-Content $outfile "$tab$tab$tab<partnumber>$($wm.partnumber)</partnumber>"
Add-Content $outfile "$tab$tab$tab<serialnumber>$($wm.serialnumber)</serialnumber>"
Add-Content $outfile "$tab$tab$tab<speed>$($wm.speed)</speed>"
Add-Content $outfile "$tab$tab</$class`_multi>"
}
Add-Content $outfile "$tab</$class>"
}
catch{
Add-Content $outfile "$tab<$class>"
Add-Content $outfile "$tab$tab<errorcode>1</errorcode>"
Add-Content $outfile "$tab$tab<errortext>$_.Exception.Message</errortext>"
Add-Content $outfile "$tab</$class>"
Write-Output "[WARNING] There was an unexpected error while getting the $class class. Moving on to next section..."
$warnings ++
}
#endregion GatherWMIPhysicalMemory
#region GatherWMIProcessor
$class = "win32_processor" # Multi item class
try{
Write-Output "[INFO] Getting details from class $class."
$props = ('addresswidth', 'caption', 'cpustatus', 'currentclockspeed', 'datawidth', 'deviceid', 'extclock', 'l2cachesize', 'l2cachespeed', 'l3cachesize', 'l3cachespeed', 'loadpercentage', 'manufacturer', 'maxclockspeed', 'name', 'numberofcores', 'numberofenabledcore', 'numberoflogicalprocessors', 'partnumber', 'powermanagementsupported', 'processortype', 'serialnumber', 'threadcount', 'vmmonitormodeextensions', 'virtualizationfirmwareenabled')
$wmi = Get-WmiObject -Namespace root/cimv2 -Class $class -ComputerName $endpoint -ErrorAction Stop | Select-Object $props | Sort-Object deviceid
Add-Content $outfile "$tab<$class>"
foreach($wm in $wmi){
Add-Content $outfile "$tab$tab<$class`_multi>"
Add-Content $outfile "$tab$tab$tab<addresswidth>$($wm.addresswidth)</addresswidth>"
Add-Content $outfile "$tab$tab$tab<caption>$($wm.caption)</caption>"
Add-Content $outfile "$tab$tab$tab<cpustatus>$($wm.cpustatus)</cpustatus>"
Add-Content $outfile "$tab$tab$tab<currentclockspeed>$($wm.currentclockspeed)</currentclockspeed>"
Add-Content $outfile "$tab$tab$tab<datawidth>$($wm.datawidth)</datawidth>"
Add-Content $outfile "$tab$tab$tab<deviceid>$($wm.deviceid)</deviceid>"
Add-Content $outfile "$tab$tab$tab<extclock>$($wm.extclock)</extclock>"
Add-Content $outfile "$tab$tab$tab<l2cachesize>$($wm.l2cachesize)</l2cachesize>"
Add-Content $outfile "$tab$tab$tab<l2cachespeed>$($wm.l2cachespeed)</l2cachespeed>"
Add-Content $outfile "$tab$tab$tab<l3cachesize>$($wm.l3cachesize)</l3cachesize>"
Add-Content $outfile "$tab$tab$tab<l3cachespeed>$($wm.l3cachespeed)</l3cachespeed>"
Add-Content $outfile "$tab$tab$tab<loadpercentage>$($wm.loadpercentage)</loadpercentage>"
Add-Content $outfile "$tab$tab$tab<manufacturer>$($wm.manufacturer)</manufacturer>"
Add-Content $outfile "$tab$tab$tab<maxclockspeed>$($wm.maxclockspeed)</maxclockspeed>"
Add-Content $outfile "$tab$tab$tab<name>$($wm.name)</name>"
Add-Content $outfile "$tab$tab$tab<numberofcores>$($wm.numberofcores)</numberofcores>"
Add-Content $outfile "$tab$tab$tab<numberofenabledcore>$($wm.numberofenabledcore)</numberofenabledcore>"
Add-Content $outfile "$tab$tab$tab<numberoflogicalprocessors>$($wm.numberoflogicalprocessors)</numberoflogicalprocessors>"
Add-Content $outfile "$tab$tab$tab<partnumber>$($wm.partnumber)</partnumber>"
Add-Content $outfile "$tab$tab$tab<powermanagementsupported>$($wm.powermanagementsupported)</powermanagementsupported>"
Add-Content $outfile "$tab$tab$tab<processortype>$($wm.processortype)</processortype>"
Add-Content $outfile "$tab$tab$tab<serialnumber>$($wm.serialnumber)</serialnumber>"
Add-Content $outfile "$tab$tab$tab<threadcount>$($wm.threadcount)</threadcount>"
Add-Content $outfile "$tab$tab$tab<vmmonitormodeextensions>$($wm.vmmonitormodeextensions)</vmmonitormodeextensions>"
Add-Content $outfile "$tab$tab$tab<virtualizationfirmwareenabled>$($wm.virtualizationfirmwareenabled)</virtualizationfirmwareenabled>"
Add-Content $outfile "$tab$tab</$class`_multi>"
}
Add-Content $outfile "$tab</$class>"
}
catch{
Add-Content $outfile "$tab<$class>"
Add-Content $outfile "$tab$tab<errorcode>1</errorcode>"
Add-Content $outfile "$tab$tab<errortext>$_.Exception.Message</errortext>"
Add-Content $outfile "$tab</$class>"
Write-Output "[WARNING] There was an unexpected error while getting the $class class. Moving on to next section..."
$warnings ++
}
#endregion GatherWMIProcessor
#region GatherWMILogicalDisk
$class = "win32_logicaldisk" # Multi item class
try{
Write-Output "[INFO] Getting details from class $class."
$props = ('deviceid', 'description', 'drivetype', 'filesystem', 'freespace', 'mediatype', 'size', 'volumename', 'volumeserialnumber')
$wmi = Get-WmiObject -Namespace root/cimv2 -Class $class -ComputerName $endpoint -ErrorAction Stop | Select-Object $props | Sort-Object deviceid
Add-Content $outfile "$tab<$class>"
foreach($wm in $wmi){
Add-Content $outfile "$tab$tab<$class`_multi>"
Add-Content $outfile "$tab$tab$tab<deviceid>$($wm.deviceid)</deviceid>"
Add-Content $outfile "$tab$tab$tab<description>$($wm.description)</description>"
Add-Content $outfile "$tab$tab$tab<drivetype>$($wm.drivetype)</drivetype>"
Add-Content $outfile "$tab$tab$tab<filesystem>$($wm.filesystem)</filesystem>"
Add-Content $outfile "$tab$tab$tab<freespace>$($wm.freespace)</freespace>"
Add-Content $outfile "$tab$tab$tab<mediatype>$($wm.mediatype)</mediatype>"
Add-Content $outfile "$tab$tab$tab<size>$($wm.size)</size>"
Add-Content $outfile "$tab$tab$tab<volumename>$($wm.volumename)</volumename>"
Add-Content $outfile "$tab$tab$tab<volumeserialnumber>$($wm.volumeserialnumber)</volumeserialnumber>"
Add-Content $outfile "$tab$tab</$class`_multi>"
}
Add-Content $outfile "$tab</$class>"
}
catch{
Add-Content $outfile "$tab<$class>"
Add-Content $outfile "$tab$tab<errorcode>1</errorcode>"
Add-Content $outfile "$tab$tab<errortext>$_.Exception.Message</errortext>"
Add-Content $outfile "$tab</$class>"
Write-Output "[WARNING] There was an unexpected error while getting the $class class. Moving on to next section..."
$warnings ++
}
#endregion GatherWMILogicalDisk
#region GatherWMIDiskPartition
$class = "win32_diskpartition" # Multi item class
try{
Write-Output "[INFO] Getting details from class $class."
$props = ('blocksize', 'bootable', 'bootpartition', 'description', 'deviceid', 'diskindex', 'numberofblocks', 'primarypartition', 'size')
$wmi = Get-WmiObject -Namespace root/cimv2 -Class $class -ComputerName $endpoint -ErrorAction Stop | Select-Object $props | Sort-Object diskindex
Add-Content $outfile "$tab<$class>"
foreach($wm in $wmi){
Add-Content $outfile "$tab$tab<$class`_multi>"
Add-Content $outfile "$tab$tab$tab<blocksize>$($wm.blocksize)</blocksize>"
Add-Content $outfile "$tab$tab$tab<bootable>$($wm.bootable)</bootable>"
Add-Content $outfile "$tab$tab$tab<bootpartition>$($wm.bootpartition)</bootpartition>"
Add-Content $outfile "$tab$tab$tab<description>$($wm.description)</description>"
Add-Content $outfile "$tab$tab$tab<deviceid>$($wm.deviceid)</deviceid>"
Add-Content $outfile "$tab$tab$tab<diskindex>$($wm.diskindex)</diskindex>"
Add-Content $outfile "$tab$tab$tab<numberofblocks>$($wm.numberofblocks)</numberofblocks>"
Add-Content $outfile "$tab$tab$tab<primarypartition>$($wm.primarypartition)</primarypartition>"
Add-Content $outfile "$tab$tab$tab<size>$($wm.size)</size>"
Add-Content $outfile "$tab$tab</$class`_multi>"
}
Add-Content $outfile "$tab</$class>"
}
catch{
Add-Content $outfile "$tab<$class>"
Add-Content $outfile "$tab$tab<errorcode>1</errorcode>"
Add-Content $outfile "$tab$tab<errortext>$_.Exception.Message</errortext>"
Add-Content $outfile "$tab</$class>"
Write-Output "[WARNING] There was an unexpected error while getting the $class class. Moving on to next section..."
$warnings ++
}
#endregion GatherWMIDiskPartition
#region GatherWMIShare
$class = "win32_share" # Multi item class
try{
Write-Output "[INFO] Getting details from class $class."
$props = ('caption', 'description', 'name', 'path', 'type')
$wmi = Get-WmiObject -Namespace root/cimv2 -Class $class -ComputerName $endpoint -ErrorAction Stop | Select-Object $props | Sort-Object name
Add-Content $outfile "$tab<$class>"
foreach($wm in $wmi){
Add-Content $outfile "$tab$tab<$class`_multi>"
Add-Content $outfile "$tab$tab$tab<caption>$($wm.caption)</caption>"
Add-Content $outfile "$tab$tab$tab<description>$($wm.description)</description>"
Add-Content $outfile "$tab$tab$tab<name>$($wm.name)</name>"
Add-Content $outfile "$tab$tab$tab<path>$($wm.path)</path>"
Add-Content $outfile "$tab$tab$tab<type>$($wm.type)</type>"
Add-Content $outfile "$tab$tab</$class`_multi>"
}
Add-Content $outfile "$tab</$class>"
}
catch{
Add-Content $outfile "$tab<$class>"
Add-Content $outfile "$tab$tab<errorcode>1</errorcode>"
Add-Content $outfile "$tab$tab<errortext>$_.Exception.Message</errortext>"
Add-Content $outfile "$tab</$class>"
Write-Output "[WARNING] There was an unexpected error while getting the $class class. Moving on to next section..."
$warnings ++
}
#endregion GatherWMIShare
#region GatherWMIStartUpCommand
$class = "win32_startupcommand" # Multi item class
try{
Write-Output "[INFO] Getting details from class $class."
$props = ('caption', 'command', 'description', 'name', 'user')
$wmi = Get-WmiObject -Namespace root/cimv2 -Class $class -ComputerName $endpoint -ErrorAction Stop | Select-Object $props | Sort-Object name
Add-Content $outfile "$tab<$class>"
foreach($wm in $wmi){
Add-Content $outfile "$tab$tab<$class`_multi>"
Add-Content $outfile "$tab$tab$tab<caption>$($wm.caption)</caption>"
Add-Content $outfile "$tab$tab$tab<command>$($wm.command)</command>"
Add-Content $outfile "$tab$tab$tab<description>$($wm.description)</description>"
Add-Content $outfile "$tab$tab$tab<name>$($wm.name)</name>"
Add-Content $outfile "$tab$tab$tab<user>$($wm.user)</user>"
Add-Content $outfile "$tab$tab</$class`_multi>"
}
Add-Content $outfile "$tab</$class>"
}
catch{
Add-Content $outfile "$tab<$class>"
Add-Content $outfile "$tab$tab<errorcode>1</errorcode>"
Add-Content $outfile "$tab$tab<errortext>$_.Exception.Message</errortext>"
Add-Content $outfile "$tab</$class>"
Write-Output "[WARNING] There was an unexpected error while getting the $class class. Moving on to next section..."
$warnings ++
}
#endregion GatherWMIStartUpCommand
#region GatherWMIPageFileUsage
$class = "win32_pagefileusage" # Multi item class
try{
Write-Output "[INFO] Getting details from class $class."
$props = ('currentusage', 'allocatedbasesize', 'caption', 'description', 'name')
$wmi = Get-WmiObject -Namespace root/cimv2 -Class $class -ComputerName $endpoint -ErrorAction Stop | Select-Object $props | Sort-Object name
Add-Content $outfile "$tab<$class>"
foreach($wm in $wmi){
Add-Content $outfile "$tab$tab<$class`_multi>"
Add-Content $outfile "$tab$tab$tab<currentusage>$($wm.currentusage)</currentusage>"
Add-Content $outfile "$tab$tab$tab<allocatedbasesize>$($wm.allocatedbasesize)</allocatedbasesize>"
Add-Content $outfile "$tab$tab$tab<caption>$($wm.caption)</caption>"
Add-Content $outfile "$tab$tab$tab<description>$($wm.description)</description>"
Add-Content $outfile "$tab$tab$tab<name>$($wm.name)</name>"
Add-Content $outfile "$tab$tab</$class`_multi>"
}
Add-Content $outfile "$tab</$class>"
}
catch{
Add-Content $outfile "$tab<$class>"
Add-Content $outfile "$tab$tab<errorcode>1</errorcode>"
Add-Content $outfile "$tab$tab<errortext>$_.Exception.Message</errortext>"
Add-Content $outfile "$tab</$class>"
Write-Output "[WARNING] There was an unexpected error while getting the $class class. Moving on to next section..."
$warnings ++
}
#endregion GatherWMIPageFileUsage
#region GatherWMIQuickFixEngineering
$class = "win32_quickfixengineering" # Multi item class
try{
Write-Output "[INFO] Getting details from class $class."
$props = ('caption', 'description', 'hotfixid', 'installedby', 'installedon')
$wmi = Get-WmiObject -Namespace root/cimv2 -Class $class -ComputerName $endpoint -ErrorAction Stop | Select-Object $props | Sort-Object hotfixid
Add-Content $outfile "$tab<$class>"
foreach($wm in $wmi){
Add-Content $outfile "$tab$tab<$class`_multi>"
Add-Content $outfile "$tab$tab$tab<caption>$($wm.caption)</caption>"
Add-Content $outfile "$tab$tab$tab<description>$($wm.description)</description>"
Add-Content $outfile "$tab$tab$tab<hotfixid>$($wm.hotfixid)</hotfixid>"
Add-Content $outfile "$tab$tab$tab<installedby>$($wm.installedby)</installedby>"
Add-Content $outfile "$tab$tab$tab<installedon>$($wm.installedon)</installedon>"
Add-Content $outfile "$tab$tab</$class`_multi>"
}
Add-Content $outfile "$tab</$class>"
}
catch{
Add-Content $outfile "$tab<$class>"
Add-Content $outfile "$tab$tab<errorcode>1</errorcode>"
Add-Content $outfile "$tab$tab<errortext>$_.Exception.Message</errortext>"
Add-Content $outfile "$tab</$class>"
Write-Output "[WARNING] There was an unexpected error while getting the $class class. Moving on to next section..."
$warnings ++
}
#endregion GatherWMIQuickFixEngineering
#region GatherWMISystemEnclosure
$class = "win32_systemenclosure" # Single item class
try{
Write-Output "[INFO] Getting details from class $class."
$props = ('chassistypes', 'lockpresent', 'manufacturer', 'model', 'securitystatus', 'serialnumber')
$wmi = Get-WmiObject -Namespace root/cimv2 -Class $class -ComputerName $endpoint -ErrorAction Stop | Select-Object $props
Add-Content $outfile "$tab<$class>"
foreach($prop in $props){
Add-Content $outfile "$tab$tab<$prop>$($wmi.$prop)</$prop>"
}
Add-Content $outfile "$tab</$class>"
}
catch{
Add-Content $outfile "$tab<$class>"
Add-Content $outfile "$tab$tab<errorcode>1</errorcode>"
Add-Content $outfile "$tab$tab<errortext>$_.Exception.Message</errortext>"
Add-Content $outfile "$tab</$class>"
Write-Output "[WARNING] There was an unexpected error while getting the $class class. Moving on to next section..."
$warnings ++
}
#endregion GatherWMISystemEnclosure
#region GatherWMIBootConfiguration
$class = "win32_bootconfiguration" # Single item class
try{
Write-Output "[INFO] Getting details from class $class."
$props = ('bootdirectory', 'caption', 'configurationpath', 'description', 'scratchdirectory')
$wmi = Get-WmiObject -Namespace root/cimv2 -Class $class -ComputerName $endpoint -ErrorAction Stop | Select-Object $props
Add-Content $outfile "$tab<$class>"
foreach($prop in $props){
Add-Content $outfile "$tab$tab<$prop>$($wmi.$prop)</$prop>"
}
Add-Content $outfile "$tab</$class>"
}
catch{
Add-Content $outfile "$tab<$class>"
Add-Content $outfile "$tab$tab<errorcode>1</errorcode>"
Add-Content $outfile "$tab$tab<errortext>$_.Exception.Message</errortext>"
Add-Content $outfile "$tab</$class>"
Write-Output "[WARNING] There was an unexpected error while getting the $class class. Moving on to next section..."
$warnings ++
}
#endregion GatherWMIBootConfiguration
#region GatherWMIBios
$class = "win32_bios" # Single item class
try{
Write-Output "[INFO] Getting details from class $class."
$props = ('biosversion', 'bioscharacteristics', 'buildnumber', 'caption', 'description', 'manufacturer', 'name', 'primarybios', 'releasedate', 'smbiosbiosversion', 'smbiosmajorversion', 'smbiosminorversion', 'smbiospresent', 'serialnumber', 'softwareelementid', 'softwareelementstate', 'systembiosmajorversion', 'systembiosminorversion', 'version')
$wmi = Get-WmiObject -Namespace root/cimv2 -Class $class -ComputerName $endpoint -ErrorAction Stop | Select-Object $props
Add-Content $outfile "$tab<$class>"
foreach($prop in $props){
Add-Content $outfile "$tab$tab<$prop>$($wmi.$prop)</$prop>"
}
Add-Content $outfile "$tab</$class>"
}
catch{
Add-Content $outfile "$tab<$class>"
Add-Content $outfile "$tab$tab<errorcode>1</errorcode>"
Add-Content $outfile "$tab$tab<errortext>$_.Exception.Message</errortext>"
Add-Content $outfile "$tab</$class>"
Write-Output "[WARNING] There was an unexpected error while getting the $class class. Moving on to next section..."
$warnings ++
}
#endregion GatherWMIBios
#region GatherWMIUserAccount
$class = "win32_useraccount" # Multi item class
try{
Write-Output "[INFO] Getting details from class $class."
$props = ('accounttype', 'caption', 'description', 'disabled', 'domain', 'fullname', 'localaccount', 'lockout', 'name', 'passwordchangeable', 'passwordexpires', 'passwordrequired', 'sid', 'sidtype')
$wmi = Get-WmiObject -Namespace root/cimv2 -Class $class -Filter "Domain='$endpoint'" -ComputerName $endpoint -ErrorAction Stop | Select-Object $props | Sort-Object name
Add-Content $outfile "$tab<$class>"
foreach($wm in $wmi){
Add-Content $outfile "$tab$tab<$class`_multi>"
Add-Content $outfile "$tab$tab$tab<accounttype>$($wm.accounttype)</accounttype>"
Add-Content $outfile "$tab$tab$tab<caption>$($wm.caption)</caption>"
Add-Content $outfile "$tab$tab$tab<description>$($wm.description)</description>"
Add-Content $outfile "$tab$tab$tab<disabled>$($wm.disabled)</disabled>"
Add-Content $outfile "$tab$tab$tab<domain>$($wm.domain)</domain>"
Add-Content $outfile "$tab$tab$tab<fullname>$($wm.fullname)</fullname>"
Add-Content $outfile "$tab$tab$tab<localaccount>$($wm.localaccount)</localaccount>"
Add-Content $outfile "$tab$tab$tab<lockout>$($wm.lockout)</lockout>"
Add-Content $outfile "$tab$tab$tab<name>$($wm.name)</name>"
Add-Content $outfile "$tab$tab$tab<passwordchangeable>$($wm.passwordchangeable)</passwordchangeable>"
Add-Content $outfile "$tab$tab$tab<passwordexpires>$($wm.passwordexpires)</passwordexpires>"
Add-Content $outfile "$tab$tab$tab<passwordrequired>$($wm.passwordrequired)</passwordrequired>"
Add-Content $outfile "$tab$tab$tab<sid>$($wm.sid)</sid>"
Add-Content $outfile "$tab$tab$tab<sidtype>$($wm.sidtype)</sidtype>"
Add-Content $outfile "$tab$tab</$class`_multi>"
}
Add-Content $outfile "$tab</$class>"
}
catch{
Add-Content $outfile "$tab<$class>"
Add-Content $outfile "$tab$tab<errorcode>1</errorcode>"
Add-Content $outfile "$tab$tab<errortext>$_.Exception.Message</errortext>"
Add-Content $outfile "$tab</$class>"
Write-Output "[WARNING] There was an unexpected error while getting the $class class. Moving on to next section..."
$warnings ++
}
#endregion GatherWMIUserAccount
#region GatherWMIGroup
$class = "win32_group" # Multi item class
try{
Write-Output "[INFO] Getting details from class $class."
$props = ('caption', 'description', 'domain', 'localaccount', 'name', 'sid', 'sidtype')
$wmi = Get-WmiObject -Namespace root/cimv2 -Class $class -Filter "Domain='$endpoint'" -ComputerName $endpoint -ErrorAction Stop | Select-Object $props | Sort-Object name
Add-Content $outfile "$tab<$class>"
foreach($wm in $wmi){
Add-Content $outfile "$tab$tab<$class`_multi>"
Add-Content $outfile "$tab$tab$tab<caption>$($wm.caption)</caption>"
Add-Content $outfile "$tab$tab$tab<description>$($wm.description)</description>"
Add-Content $outfile "$tab$tab$tab<domain>$($wm.domain)</domain>"
Add-Content $outfile "$tab$tab$tab<localaccount>$($wm.localaccount)</localaccount>"
Add-Content $outfile "$tab$tab$tab<name>$($wm.name)</name>"
Add-Content $outfile "$tab$tab$tab<sid>$($wm.sid)</sid>"
Add-Content $outfile "$tab$tab$tab<sidtype>$($wm.sidtype)</sidtype>"
Add-Content $outfile "$tab$tab</$class`_multi>"
}
Add-Content $outfile "$tab</$class>"
}
catch{
Add-Content $outfile "$tab<$class>"
Add-Content $outfile "$tab$tab<errorcode>1</errorcode>"
Add-Content $outfile "$tab$tab<errortext>$_.Exception.Message</errortext>"
Add-Content $outfile "$tab</$class>"
Write-Output "[WARNING] There was an unexpected error while getting the $class class. Moving on to next section..."
$warnings ++
}
#endregion GatherWMIGroup
#region GatherWMIGroupMembership
$class = "win32_group" # Multi item class
try{
Write-Output "[INFO] Getting details from class $class and querying membership."
$props = ('caption', 'description', 'domain', 'localaccount', 'name', 'sid', 'sidtype')
$groups = Get-WmiObject -Namespace root/cimv2 -Class $class -Filter "Domain='$endpoint'" -ComputerName $endpoint -ErrorAction Stop | Select-Object $props | Sort-Object name
Add-Content $outfile "$tab<$class`_membership>"
foreach($group in $groups){
$query = "GroupComponent = `"$class.Domain='$($group.domain)',Name='$($group.Name)'`""
$users = (Get-WmiObject -Namespace root/cimv2 -Class win32_groupuser -Filter $query).PartComponent
Add-Content $outfile "$tab$tab<$class`_multi>"
Add-Content $outfile "$tab$tab$tab<name>$($group.Domain +'\' + $group.Name)</name>"
Add-Content $outfile "$tab$tab$tab$tab<members>"
foreach ($user in $users){
$domain = $user.Substring($user.IndexOf("`"")+1)
$u = $domain
$domain = $domain.Substring(0,$domain.IndexOf("`""))
$u = $u.Substring($u.IndexOf("`"")+1)
$u = $u.Substring($u.IndexOf("`"")+1)
$u = $u.Substring(0,($u.Length-1))
Add-Content $outfile "$tab$tab$tab$tab$tab<member>$($domain +'\' + $u)</member>"
}
Add-Content $outfile "$tab$tab$tab$tab</members>"
Add-Content $outfile "$tab$tab</$class`_multi>"
}
Add-Content $outfile "$tab</$class`_membership>"
}
catch{
Add-Content $outfile "$tab<$class>"
Add-Content $outfile "$tab$tab<errorcode>1</errorcode>"
Add-Content $outfile "$tab$tab<errortext>$_.Exception.Message</errortext>"
Add-Content $outfile "$tab</$class>"
Write-Output "[WARNING] There was an unexpected error while getting the $class class. Moving on to next section..."
$warnings ++
}
#endregion GatherWMIGroupMembership
#region GatherWMISystemAccounts
$class = "win32_systemaccount" # Multi item class
try{
Write-Output "[INFO] Getting details from class $class."
$props = ('caption', 'description', 'domain', 'localaccount', 'name', 'sid', 'sidtype')
$wmi = Get-WmiObject -Namespace root/cimv2 -Class $class -Filter "Domain='$endpoint'" -ComputerName $endpoint -ErrorAction Stop | Select-Object $props | Sort-Object name
Add-Content $outfile "$tab<$class>"
foreach($wm in $wmi){
Add-Content $outfile "$tab$tab<$class`_multi>"
Add-Content $outfile "$tab$tab$tab<caption>$($wm.caption)</caption>"
Add-Content $outfile "$tab$tab$tab<description>$($wm.description)</description>"
Add-Content $outfile "$tab$tab$tab<domain>$($wm.domain)</domain>"
Add-Content $outfile "$tab$tab$tab<localaccount>$($wm.localaccount)</localaccount>"
Add-Content $outfile "$tab$tab$tab<name>$($wm.name)</name>"
Add-Content $outfile "$tab$tab$tab<sid>$($wm.sid)</sid>"
Add-Content $outfile "$tab$tab$tab<sidtype>$($wm.sidtype)</sidtype>"
Add-Content $outfile "$tab$tab</$class`_multi>"
}
Add-Content $outfile "$tab</$class>"
}
catch{
Add-Content $outfile "$tab<$class>"
Add-Content $outfile "$tab$tab<errorcode>1</errorcode>"
Add-Content $outfile "$tab$tab<errortext>$_.Exception.Message</errortext>"
Add-Content $outfile "$tab</$class>"
Write-Output "[WARNING] There was an unexpected error while getting the $class class. Moving on to next section..."
$warnings ++
}
#endregion GatherWMISystemAccounts
#region GatherWMIService
$class = "win32_service" # Multi item class
try{
Write-Output "[INFO] Getting details from class $class."
$props = ('caption', 'delayedautostart', 'description', 'displayname', 'name', 'pathname', 'started', 'startmode', 'startname', 'state')
$wmi = Get-WmiObject -Namespace root/cimv2 -Class $class -ComputerName $endpoint -ErrorAction Stop | Select-Object $props | Sort-Object caption
Add-Content $outfile "$tab<$class>"
foreach($wm in $wmi){
Add-Content $outfile "$tab$tab<$class`_multi>"
Add-Content $outfile "$tab$tab$tab<caption>$($wm.caption)</caption>"
Add-Content $outfile "$tab$tab$tab<delayedautostart>$($wm.delayedautostart)</delayedautostart>"
Add-Content $outfile "$tab$tab$tab<description>$($wm.description)</description>"
Add-Content $outfile "$tab$tab$tab<displayname>$($wm.displayname)</displayname>"
Add-Content $outfile "$tab$tab$tab<name>$($wm.name)</name>"
Add-Content $outfile "$tab$tab$tab<pathname>$($wm.pathname)</pathname>"
Add-Content $outfile "$tab$tab$tab<started>$($wm.started)</started>"
Add-Content $outfile "$tab$tab$tab<startmode>$($wm.startmode)</startmode>"
Add-Content $outfile "$tab$tab$tab<startname>$($wm.startname)</startname>"
Add-Content $outfile "$tab$tab$tab<state>$($wm.state)</state>"
Add-Content $outfile "$tab$tab</$class`_multi>"
}
Add-Content $outfile "$tab</$class>"
}
catch{
Add-Content $outfile "$tab<$class>"
Add-Content $outfile "$tab$tab<errorcode>1</errorcode>"
Add-Content $outfile "$tab$tab<errortext>$_.Exception.Message</errortext>"
Add-Content $outfile "$tab</$class>"
Write-Output "[WARNING] There was an unexpected error while getting the $class class. Moving on to next section..."
$warnings ++
}
#endregion GatherWMIService
#region GatherWMIProcess
$class = "win32_process" # Multi item class
try{
Write-Output "[INFO] Getting details from class $class."
$props = ('caption', 'description', 'name', 'processname')
$wmi = Get-WmiObject -Namespace root/cimv2 -Class $class -ComputerName $endpoint -ErrorAction Stop | Select-Object $props | Sort-Object name
Add-Content $outfile "$tab<$class>"
foreach($wm in $wmi){
Add-Content $outfile "$tab$tab<$class`_multi>"
Add-Content $outfile "$tab$tab$tab<caption>$($wm.caption)</caption>"
Add-Content $outfile "$tab$tab$tab<description>$($wm.description)</description>"
Add-Content $outfile "$tab$tab$tab<name>$($wm.name)</name>"
Add-Content $outfile "$tab$tab$tab<processname>$($wm.processname)</processname>"
Add-Content $outfile "$tab$tab</$class`_multi>"
}
Add-Content $outfile "$tab</$class>"
}
catch{
Add-Content $outfile "$tab<$class>"
Add-Content $outfile "$tab$tab<errorcode>1</errorcode>"
Add-Content $outfile "$tab$tab<errortext>$_.Exception.Message</errortext>"
Add-Content $outfile "$tab</$class>"
Write-Output "[WARNING] There was an unexpected error while getting the $class class. Moving on to next section..."
$warnings ++
}
#endregion GatherWMIProcess
#region GatherWMISystemDriver
$class = "win32_systemdriver" # Multi item class
try{
Write-Output "[INFO] Getting details from class $class."
$props = ('caption', 'description', 'displayname', 'name', 'servicetype', 'startmode', 'started', 'state')
$wmi = Get-WmiObject -Namespace root/cimv2 -Class $class -ComputerName $endpoint -ErrorAction Stop | Select-Object $props | Sort-Object name
Add-Content $outfile "$tab<$class>"
foreach($wm in $wmi){
Add-Content $outfile "$tab$tab<$class`_multi>"
Add-Content $outfile "$tab$tab$tab<caption>$($wm.caption)</caption>"
Add-Content $outfile "$tab$tab$tab<description>$($wm.description)</description>"
Add-Content $outfile "$tab$tab$tab<displayname>$($wm.displayname)</displayname>"
Add-Content $outfile "$tab$tab$tab<name>$($wm.name)</name>"
Add-Content $outfile "$tab$tab$tab<servicetype>$($wm.servicetype)</servicetype>"
Add-Content $outfile "$tab$tab$tab<startmode>$($wm.startmode)</startmode>"
Add-Content $outfile "$tab$tab$tab<started>$($wm.started)</started>"
Add-Content $outfile "$tab$tab$tab<state>$($wm.state)</state>"
Add-Content $outfile "$tab$tab</$class`_multi>"
}
Add-Content $outfile "$tab</$class>"
}
catch{
Add-Content $outfile "$tab<$class>"
Add-Content $outfile "$tab$tab<errorcode>1</errorcode>"
Add-Content $outfile "$tab$tab<errortext>$_.Exception.Message</errortext>"
Add-Content $outfile "$tab</$class>"
Write-Output "[WARNING] There was an unexpected error while getting the $class class. Moving on to next section..."
$warnings ++
}
#endregion GatherWMISystemDriver
#region GatherWMIPNPEntity
$class = "win32_pnpentity" # Multi item class
try{
Write-Output "[INFO] Getting details from class $class."
$props = ('caption', 'classguid', 'compatibleid', 'description', 'deviceid', 'hardwareid', 'manufacturer', 'name', 'pnpclass', 'pnpdeviceid', 'present', 'service')
$wmi = Get-WmiObject -Namespace root/cimv2 -Class $class -ComputerName $endpoint -ErrorAction Stop | Select-Object $props | Sort-Object caption
Add-Content $outfile "$tab<$class>"
foreach($wm in $wmi){
Add-Content $outfile "$tab$tab<$class`_multi>"
Add-Content $outfile "$tab$tab$tab<caption>$($wm.caption)</caption>"
Add-Content $outfile "$tab$tab$tab<classguid>$($wm.classguid)</classguid>"
Add-Content $outfile "$tab$tab$tab<compatibleid>$($wm.compatibleid)</compatibleid>"
Add-Content $outfile "$tab$tab$tab<description>$($wm.description)</description>"
Add-Content $outfile "$tab$tab$tab<deviceid>$($wm.deviceid)</deviceid>"
Add-Content $outfile "$tab$tab$tab<hardwareid>$($wm.hardwareid)</hardwareid>"
Add-Content $outfile "$tab$tab$tab<manufacturer>$($wm.manufacturer)</manufacturer>"
Add-Content $outfile "$tab$tab$tab<name>$($wm.name)</name>"
Add-Content $outfile "$tab$tab$tab<pnpclass>$($wm.pnpclass)</pnpclass>"
Add-Content $outfile "$tab$tab$tab<pnpdeviceid>$($wm.pnpdeviceid)</pnpdeviceid>"
Add-Content $outfile "$tab$tab$tab<present>$($wm.present)</present>"
Add-Content $outfile "$tab$tab$tab<service>$($wm.service)</service>"
Add-Content $outfile "$tab$tab</$class`_multi>"
}
Add-Content $outfile "$tab</$class>"
}
catch{
Add-Content $outfile "$tab<$class>"
Add-Content $outfile "$tab$tab<errorcode>1</errorcode>"
Add-Content $outfile "$tab$tab<errortext>$_.Exception.Message</errortext>"
Add-Content $outfile "$tab</$class>"
Write-Output "[WARNING] There was an unexpected error while getting the $class class. Moving on to next section..."
$warnings ++
}
#endregion GatherWMIPNPEntity
#region GatherWMITimezone
$class = "win32_timezone" # Single item class
try{
Write-Output "[INFO] Getting details from class $class."