forked from lework/script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathADDS_Inventory_V2.ps1
16523 lines (14914 loc) · 527 KB
/
ADDS_Inventory_V2.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
#Requires -Version 3.0
#requires -Module ActiveDirectory
#requires -Module GroupPolicy
#This File is in Unicode format. Do not edit in an ASCII editor. Notepad++ UTF-8-BOM
<#
.SYNOPSIS
Creates a complete inventory of a Microsoft Active Directory Forest.
.DESCRIPTION
Creates a complete inventory of a Microsoft Active Directory Forest using Microsoft
PowerShell, Word, plain text, or HTML.
Creates a Word or PDF document, text or HTML file named after the Active Directory Forest.
Word and PDF document includes a Cover Page, Table of Contents and Footer.
Includes support for the following language versions of Microsoft Word:
Catalan
Chinese
Danish
Dutch
English
Finnish
French
German
Norwegian
Portuguese
Spanish
Swedish
The script requires at least PowerShell version 3 but runs best in version 5.
Word is NOT needed to run the script. This script will output in Text and HTML.
You do NOT have to run this script on a domain controller. This script was developed
and run from a Windows 10 VM.
While most of the script can be run with a non-admin account, there are some features
that will not or may not work without domain admin or enterprise admin rights.
The Hardware and Services parameters require domain admin privileges.
Version 2.0 of the script adds gathering information on Time Server and AD database,
log file, and SYSVOL locations. Those require access to the registry on each domain
controller, which means the script should now always be run from an elevated PowerShell
session with an account with a minimum of domain admin rights.
Running the script in a forest with multiple domains requires Enterprise Admin rights.
The count of all users may not be accurate if the user running the script doesn't have
the necessary permissions on all user objects. In that case, there may be user accounts
classified as "unknown".
To run the script from a workstation, RSAT is required.
Remote Server Administration Tools for Windows 7 with Service Pack 1 (SP1)
http://www.microsoft.com/en-us/download/details.aspx?id=7887
Remote Server Administration Tools for Windows 8
http://www.microsoft.com/en-us/download/details.aspx?id=28972
Remote Server Administration Tools for Windows 8.1
http://www.microsoft.com/en-us/download/details.aspx?id=39296
Remote Server Administration Tools for Windows 10
http://www.microsoft.com/en-us/download/details.aspx?id=45520
.PARAMETER HTML
Creates an HTML file with an .html extension.
This parameter is disabled by default.
.PARAMETER MSWord
SaveAs DOCX file
This parameter is set True if no other output format is selected.
.PARAMETER PDF
SaveAs PDF file instead of DOCX file.
This parameter is disabled by default.
The PDF file is roughly 5X to 10X larger than the DOCX file.
This parameter requires Microsoft Word to be installed.
This parameter uses the Word SaveAs PDF capability.
.PARAMETER Text
Creates a formatted text file with a .txt extension.
This parameter is disabled by default.
.PARAMETER AddDateTime
Adds a date time stamp to the end of the file name.
The timestamp is in the format of yyyy-MM-dd_HHmm.
June 1, 2020 at 6PM is 2020-06-01_1800.
Output filename will be ReportName_2020-06-01_1800.docx (or .pdf).
This parameter is disabled by default.
.PARAMETER ADDomain
Specifies an Active Directory domain object by providing one of the following
property values. The identifier in parentheses is the LDAP display name for the
attribute. All values are for the domainDNS object that represents the domain.
Distinguished Name
Example: DC=tullahoma,DC=corp,DC=labaddomain,DC=com
GUID (objectGUID)
Example: b9fa5fbd-4334-4a98-85f1-3a3a44069fc6
Security Identifier (objectSid)
Example: S-1-5-21-3643273344-1505409314-3732760578
DNS domain name
Example: tullahoma.corp.labaddomain.com
NetBIOS domain name
Example: Tullahoma
If both ADForest and ADDomain are specified, ADDomain takes precedence.
.PARAMETER ADForest
Specifies an Active Directory forest object by providing one of the following
attribute values.
The identifier in parentheses is the LDAP display name for the attribute.
Fully qualified domain name
Example: labaddomain.com
GUID (objectGUID)
Example: 599c3d2e-e61e-4d20-7b77-030d99495e19
DNS host name
Example: labaddomain.com
NetBIOS name
Example: labaddomain
Default value is $Env:USERDNSDOMAIN
If both ADForest and ADDomain are specified, ADDomain takes precedence.
.PARAMETER CompanyAddress
Company Address to use for the Cover Page, if the Cover Page has the Address field.
The following Cover Pages have an Address field:
Banded (Word 2013/2016)
Contrast (Word 2010)
Exposure (Word 2010)
Filigree (Word 2013/2016)
Ion (Dark) (Word 2013/2016)
Retrospect (Word 2013/2016)
Semaphore (Word 2013/2016)
Tiles (Word 2010)
ViewMaster (Word 2013/2016)
This parameter is only valid with the MSWORD and PDF output parameters.
This parameter has an alias of CA.
.PARAMETER CompanyEmail
Company Email to use for the Cover Page, if the Cover Page has the Email field.
The following Cover Pages have an Email field:
Facet (Word 2013/2016)
This parameter is only valid with the MSWORD and PDF output parameters.
This parameter has an alias of CE.
.PARAMETER CompanyFax
Company Fax to use for the Cover Page, if the Cover Page has the Fax field.
The following Cover Pages have a Fax field:
Contrast (Word 2010)
Exposure (Word 2010)
This parameter is only valid with the MSWORD and PDF output parameters.
This parameter has an alias of CF.
.PARAMETER CompanyName
Company Name to use for the Cover Page.
Default value is contained in
HKCU:\Software\Microsoft\Office\Common\UserInfo\CompanyName or
HKCU:\Software\Microsoft\Office\Common\UserInfo\Company, whichever is populated
on the computer running the script.
This parameter has an alias of CN.
If either registry key does not exist and this parameter is not specified, the report
will not contain a Company Name on the cover page.
This parameter is only valid with the MSWORD and PDF output parameters.
.PARAMETER CompanyPhone
Company Phone to use for the Cover Page if the Cover Page has the Phone field.
The following Cover Pages have a Phone field:
Contrast (Word 2010)
Exposure (Word 2010)
This parameter is only valid with the MSWORD and PDF output parameters.
This parameter has an alias of CPh.
.PARAMETER CoverPage
What Microsoft Word Cover Page to use.
Only Word 2010, 2013 and 2016 are supported.
(default cover pages in Word en-US)
Valid input is:
Alphabet (Word 2010. Works)
Annual (Word 2010. Doesn't work well for this report)
Austere (Word 2010. Works)
Austin (Word 2010/2013/2016. Doesn't work in 2013 or 2016, mostly
works in 2010 but Subtitle/Subject & Author fields need to be moved
after title box is moved up)
Banded (Word 2013/2016. Works)
Conservative (Word 2010. Works)
Contrast (Word 2010. Works)
Cubicles (Word 2010. Works)
Exposure (Word 2010. Works if you like looking sideways)
Facet (Word 2013/2016. Works)
Filigree (Word 2013/2016. Works)
Grid (Word 2010/2013/2016. Works in 2010)
Integral (Word 2013/2016. Works)
Ion (Dark) (Word 2013/2016. Top date doesn't fit; box needs to be
manually resized or font changed to 8 point)
Ion (Light) (Word 2013/2016. Top date doesn't fit; box needs to be
manually resized or font changed to 8 point)
Mod (Word 2010. Works)
Motion (Word 2010/2013/2016. Works if top date is manually changed to
36 point)
Newsprint (Word 2010. Works but date is not populated)
Perspective (Word 2010. Works)
Pinstripes (Word 2010. Works)
Puzzle (Word 2010. Top date doesn't fit; box needs to be manually
resized or font changed to 14 point)
Retrospect (Word 2013/2016. Works)
Semaphore (Word 2013/2016. Works)
Sideline (Word 2010/2013/2016. Doesn't work in 2013 or 2016, works in
2010)
Slice (Dark) (Word 2013/2016. Doesn't work)
Slice (Light) (Word 2013/2016. Doesn't work)
Stacks (Word 2010. Works)
Tiles (Word 2010. Date doesn't fit unless changed to 26 point)
Transcend (Word 2010. Works)
ViewMaster (Word 2013/2016. Works)
Whisp (Word 2013/2016. Works)
The default value is Sideline.
This parameter has an alias of CP.
This parameter is only valid with the MSWORD and PDF output parameters.
.PARAMETER ComputerName
Specifies which domain controller to use to run the script against.
If ADForest is a trusted forest, then ComputerName is required to detect the
existence of ADForest.
ComputerName can be entered as the NetBIOS name, FQDN, localhost or IP Address.
If entered as localhost, the actual computer name is determined and used.
If entered as an IP address, an attempt is made to determine and use the actual
computer name.
This parameter has an alias of ServerName.
Default value is $Env:USERDNSDOMAIN
.PARAMETER DCDNSInfo
Use WMI to gather, for each domain controller, the IP Address, and each DNS server
configured.
This parameter requires the script be run from an elevated PowerShell session
using an account with permission to retrieve hardware information (i.e. Domain
Admin).
Selecting this parameter will add an extra section to the report.
This parameter is disabled by default.
.PARAMETER Dev
Clears errors at the beginning of the script.
Outputs all errors to a text file at the end of the script.
This is used when the script developer requests more troubleshooting data.
The text file is placed in the same folder from where the script is run.
This parameter is disabled by default.
.PARAMETER Folder
Specifies the optional output folder to save the output report.
.PARAMETER GPOInheritance
In the Group Policies by OU section, adds Inherited GPOs in addition to the GPOs
directly linked.
Adds a second column to the table GPO Type.
The text file is placed in the same folder from where the script is run.
This parameter is disabled by default.
This parameter has an alias of GPO.
.PARAMETER Hardware
Use WMI to gather hardware information on Computer System, Disks, Processor, and
Network Interface Cards
This parameter requires the script be run from an elevated PowerShell session
using an account with permission to retrieve hardware information (i.e. Domain
Admin).
Selecting this parameter will add to both the time it takes to run the script and
size of the report.
This parameter is disabled by default.
.PARAMETER IncludeUserInfo
For the User Miscellaneous Data section outputs a table with the SamAccountName
and DistinguishedName of the users in the All Users counts:
Disabled users
Unknown users
Locked out users
All users with password expired
All users whose password never expires
All users with password not required
All users who cannot change password
All users with SID History
All users with Homedrive set in ADUC
All users whose Primary Group is not Domain Users
All users with RDS HomeDrive set in ADUC
The Text output option is limited to the first 25 characters of the SamAccountName
and the first 116 characters of the DistinguishedName.
This parameter is disabled by default.
This parameter has an alias of IU.
.PARAMETER Log
Generates a log file for troubleshooting.
.PARAMETER MaxDetails
Adds maximum detail to the report.
This is the same as using the following parameters:
DCDNSInfo
GPOInheritance
Hardware
IncludeUserInfo
Services
WARNING: Using this parameter can create an extremely large report and
can take a very long time to run.
This parameter has an alias of MAX.
.PARAMETER ScriptInfo
Outputs information about the script to a text file.
The text file is placed in the same folder from where the script is run.
This parameter is disabled by default.
This parameter has an alias of SI.
.PARAMETER Services
Gather information on all services running on domain controllers.
Servers that are configured to automatically start but are not running will be
colored in red.
Used on Domain Controllers only.
This parameter requires the script be run from an elevated PowerShell session
using an account with permission to retrieve service information (i.e. Domain
Admin).
Selecting this parameter will add to both the time it takes to run the script and
size of the report.
This parameter is disabled by default.
.PARAMETER Section
Processes one or more sections of the report.
Valid options are:
Forest
Sites
Domains (includes Domain Controllers and optional Hardware, Services and
DCDNSInfo)
OUs (Organizational Units)
Groups
GPOs
Misc (Miscellaneous data)
All
This parameter defaults to All sections.
Multiple sections are separated by a comma. -Section forest, domains
.PARAMETER UserName
Username to use for the Cover Page and Footer.
Default value is contained in $env:username
This parameter has an alias of UN.
This parameter is only valid with the MSWORD and PDF output parameters.
.PARAMETER SmtpServer
Specifies the optional email server to send the output report.
.PARAMETER SmtpPort
Specifies the SMTP port.
The default is 25.
.PARAMETER UseSSL
Specifies whether to use SSL for the SmtpServer.
The default is False.
.PARAMETER From
Specifies the username for the From email address.
If SmtpServer is used, this is a required parameter.
.PARAMETER To
Specifies the username for the To email address.
If SmtpServer is used, this is a required parameter.
.EXAMPLE
PS C:\PSScript > .\ADDS_Inventory_V2.ps1
Will use all default values.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Carl
Webster" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Carl Webster"
$env:username = Administrator
Carl Webster for the Company Name.
Sideline for the Cover Page format.
Administrator for the User Name.
ADForest defaults to the value of $Env:USERDNSDOMAIN.
ComputerName defaults to the value of $Env:USERDNSDOMAIN, then the script queries for
a domain controller that is also a global catalog server and will use that as the
value for ComputerName.
.EXAMPLE
PS C:\PSScript > .\ADDS_Inventory_V2.ps1 -ADForest company.tld
Will use all default values.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Carl
Webster" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Carl Webster"
$env:username = Administrator
Carl Webster for the Company Name.
Sideline for the Cover Page format.
Administrator for the User Name.
company.tld for the AD Forest.
ComputerName defaults to the value of $Env:USERDNSDOMAIN, then the script queries for
a domain controller that is also a global catalog server and will use that as the
value for ComputerName.
.EXAMPLE
PS C:\PSScript > .\ADDS_Inventory_V2.ps1 -ADDomain child.company.tld
Will use all default values.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Carl
Webster" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Carl Webster"
$env:username = Administrator
Carl Webster for the Company Name.
Sideline for the Cover Page format.
Administrator for the User Name.
child.company.tld for the AD Domain.
ComputerName defaults to the value of $Env:USERDNSDOMAIN, then the script queries for
a domain controller that is also a global catalog server and will use that as the
value for ComputerName.
.EXAMPLE
PS C:\PSScript > .\ADDS_Inventory_V2.ps1 -ADForest parent.company.tld
-ADDomain child.company.tld
Will use all default values.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Carl
Webster" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Carl Webster"
$env:username = Administrator
Carl Webster for the Company Name.
Sideline for the Cover Page format.
Administrator for the User Name.
Because both ADForest and ADDomain are specified, ADDomain wins and child.company.tld
is used for AD Domain.
ADForest is set to the value of ADDomain.
ComputerName defaults to the value of $Env:USERDNSDOMAIN, then the script queries for
a domain controller that is also a global catalog server and will use that as the
value for ComputerName.
.EXAMPLE
PS C:\PSScript > .\ADDS_Inventory_V2.ps1 -ADForest company.tld -ComputerName DC01
Will use all default values.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Carl
Webster" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Carl Webster"
$env:username = Administrator
Carl Webster for the Company Name.
Sideline for the Cover Page format.
Administrator for the User Name.
company.tld for the AD Forest
The script will be run remotely on the DC01 domain controller.
.EXAMPLE
PS C:\PSScript > .\ADDS_Inventory_V2.ps1 -PDF -ADForest corp.carlwebster.com
Will use all default values and save the document as a PDF file.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Carl
Webster" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Carl Webster"
$env:username = Administrator
Carl Webster for the Company Name.
Sideline for the Cover Page format.
Administrator for the User Name.
corp.carlwebster.com for the AD Forest.
ComputerName defaults to the value of $Env:USERDNSDOMAIN, then the script queries for
a domain controller that is also a global catalog server and will use that as the
value for ComputerName.
.EXAMPLE
PS C:\PSScript > .\ADDS_Inventory_V2.ps1 -Text -ADForest corp.carlwebster.com
Will use all default values and save the document as a formatted text file.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Carl
Webster" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Carl Webster"
$env:username = Administrator.
Carl Webster for the Company Name.
Sideline for the Cover Page format.
Administrator for the User Name.
corp.carlwebster.com for the AD Forest.
ComputerName defaults to the value of $Env:USERDNSDOMAIN, then the script queries for
a domain controller that is also a global catalog server and will use that as the
value for ComputerName.
.EXAMPLE
PS C:\PSScript > .\ADDS_Inventory_V2.ps1 -HTML -ADForest corp.carlwebster.com
Will use all default values and save the document as an HTML file.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Carl
Webster" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Carl Webster"
$env:username = Administrator.
Carl Webster for the Company Name.
Sideline for the Cover Page format.
Administrator for the User Name.
corp.carlwebster.com for the AD Forest.
ComputerName defaults to the value of $Env:USERDNSDOMAIN, then the script queries for
a domain controller that is also a global catalog server and will use that as the
value for ComputerName.
.EXAMPLE
PS C:\PSScript > .\ADDS_Inventory_V2.ps1 -hardware
Will use all default values and add additional information for each domain controller
about its hardware.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Carl
Webster" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Carl Webster"
$env:username = Administrator.
Carl Webster for the Company Name.
Sideline for the Cover Page format.
Administrator for the User Name.
ADForest defaults to the value of $Env:USERDNSDOMAIN.
ComputerName defaults to the value of $Env:USERDNSDOMAIN, then the script queries for
a domain controller that is also a global catalog server and will use that as the
value for ComputerName.
.EXAMPLE
PS C:\PSScript > .\ADDS_Inventory_V2.ps1 -services
Will use all default values and add additional information for the services running
on each domain controller.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Carl
Webster" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Carl Webster"
$env:username = Administrator.
Carl Webster for the Company Name.
Sideline for the Cover Page format.
Administrator for the User Name.
ADForest defaults to the value of $Env:USERDNSDOMAIN.
ComputerName defaults to the value of $Env:USERDNSDOMAIN, then the script queries for
a domain controller that is also a global catalog server and will use that as the
value for ComputerName.
.EXAMPLE
PS C:\PSScript > .\ADDS_Inventory_V2.ps1 -DCDNSInfo
Will use all default values and add additional information for each domain controller
about its DNS IP configuration.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Carl
Webster" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Carl Webster"
$env:username = Administrator
Carl Webster for the Company Name.
Sideline for the Cover Page format.
Administrator for the User Name.
An extra section will be added to the end of the report.
ADForest defaults to the value of $Env:USERDNSDOMAIN.
ComputerName defaults to the value of $Env:USERDNSDOMAIN, then the script queries for
a domain controller that is also a global catalog server and will use that as the
value for ComputerName.
.EXAMPLE
PS C:\PSScript .\ADDS_Inventory_V2.ps1 -CompanyName "Carl Webster Consulting"
-CoverPage "Mod" -UserName "Carl Webster" -ComputerName ADDC01
Will use:
Carl Webster Consulting for the Company Name.
Mod for the Cover Page format.
Carl Webster for the User Name.
ADForest defaults to the value of $Env:USERDNSDOMAIN.
Domain Controller named ADDC01 for the ComputerName.
.EXAMPLE
PS C:\PSScript .\ADDS_Inventory_V2.ps1 -CN "Carl Webster Consulting" -CP "Mod"
-UN "Carl Webster"
Will use:
Carl Webster Consulting for the Company Name (alias CN).
Mod for the Cover Page format (alias CP).
Carl Webster for the User Name (alias UN).
ADForest defaults to the value of $Env:USERDNSDOMAIN.
ComputerName defaults to the value of $Env:USERDNSDOMAIN, then the script queries for
a domain controller that is also a global catalog server and will use that as the
value for ComputerName.
.EXAMPLE
PS C:\PSScript .\ADDS_Inventory_V2.ps1 -CompanyName "Sherlock Holmes
Consulting"
-CoverPage Exposure -UserName "Dr. Watson"
-CompanyAddress "221B Baker Street, London, England"
-CompanyFax "+44 1753 276600"
-CompanyPhone "+44 1753 276200"
Will use:
Sherlock Holmes Consulting for the Company Name.
Exposure for the Cover Page format.
Dr. Watson for the User Name.
221B Baker Street, London, England for the Company Address.
+44 1753 276600 for the Company Fax.
+44 1753 276200 for the Company Phone.
ADForest defaults to the value of $Env:USERDNSDOMAIN.
ComputerName defaults to the value of $Env:USERDNSDOMAIN, then the script queries for
a domain controller that is also a global catalog server and will use that as the
value for ComputerName.
.EXAMPLE
PS C:\PSScript .\ADDS_Inventory_V2.ps1 -CompanyName "Sherlock Holmes
Consulting"
-CoverPage Facet -UserName "Dr. Watson"
-CompanyEmail [email protected]
Will use:
Sherlock Holmes Consulting for the Company Name.
Facet for the Cover Page format.
Dr. Watson for the User Name.
[email protected] for the Company Email.
ADForest defaults to the value of $Env:USERDNSDOMAIN.
ComputerName defaults to the value of $Env:USERDNSDOMAIN, then the script queries for
a domain controller that is also a global catalog server and will use that as the
value for ComputerName.
.EXAMPLE
PS C:\PSScript > .\ADDS_Inventory_V2.ps1 -ADForest company.tld -AddDateTime
Will use all default values.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Carl
Webster" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Carl Webster"
$env:username = Administrator.
Carl Webster for the Company Name.
Sideline for the Cover Page format.
Administrator for the User Name.
company.tld for the AD Forest.
ComputerName defaults to the value of $Env:USERDNSDOMAIN, then the script queries for
a domain controller that is also a global catalog server and will use that as the
value for ComputerName.
Adds a date time stamp to the end of the file name.
The timestamp is in the format of yyyy-MM-dd_HHmm.
June 1, 2020 at 6PM is 2020-06-01_1800.
Output filename will be company.tld_2020-06-01_1800.docx.
.EXAMPLE
PS C:\PSScript > .\ADDS_Inventory_V2.ps1 -PDF -ADForest corp.carlwebster.com
-AddDateTime
Will use all default values and save the document as a PDF file.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Carl
Webster" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Carl Webster"
$env:username = Administrator
Carl Webster for the Company Name.
Sideline for the Cover Page format.
Administrator for the User Name.
corp.carlwebster.com for the AD Forest.
ComputerName defaults to the value of $Env:USERDNSDOMAIN, then the script queries for
a domain controller that is also a global catalog server and will use that as the
value for ComputerName.
Adds a date time stamp to the end of the file name.
The timestamp is in the format of yyyy-MM-dd_HHmm.
June 1, 2020 at 6PM is 2020-06-01_1800.
Output filename will be corp.carlwebster.com_2020-06-01_1800.PDF
.EXAMPLE
PS C:\PSScript > .\ADDS_Inventory_V2.ps1 -ADForest corp.carlwebster.com
-Folder \\FileServer\ShareName
Will use all default values.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Carl
Webster" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Carl Webster"
$env:username = Administrator
Carl Webster for the Company Name.
Sideline for the Cover Page format.
Administrator for the User Name.
corp.carlwebster.com for the AD Forest.
ComputerName defaults to the value of $Env:USERDNSDOMAIN, then the script queries for
a domain controller that is also a global catalog server and will use that as the
value for ComputerName.
The output file will be saved in the path \\FileServer\ShareName.
.EXAMPLE
PS C:\PSScript > .\ADDS_Inventory_V2.ps1 -Section Forest
Will use all default values.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Carl
Webster" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Carl Webster"
$env:username = Administrator
Carl Webster for the Company Name.
Sideline for the Cover Page format.
Administrator for the User Name.
ADForest defaults to the value of $Env:USERDNSDOMAIN
ComputerName defaults to the value of $Env:USERDNSDOMAIN, then the script queries for
a domain controller that is also a global catalog server and will use that as the
value for ComputerName.
The report will include only the Forest section.
.EXAMPLE
PS C:\PSScript > .\ADDS_Inventory_V2.ps1 -Section groups, misc
-ADForest WebstersLab.com -ServerName PrimaryDC.websterslab.com
Will use all default values.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Carl
Webster" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Carl Webster"
$env:username = Administrator
Carl Webster for the Company Name.
Sideline for the Cover Page format.
Administrator for the User Name.
WebstersLab.com for ADForest.
PrimaryDC.websterslab.com for ComputerName.
The report will include only the Groups and Miscellaneous sections.
.EXAMPLE
PS C:\PSScript > .\ADDS_Inventory_V2.ps1 -MaxDetails
Will use all Default values.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Carl
Webster" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Carl Webster"
$env:username = Administrator
Carl Webster for the Company Name.
Sideline for the Cover Page format.
Administrator for the User Name.
Set the following parameter values:
DCDNSInfo = True
GPOInheritance = True
Hardware = True
IncludeUserInfo = True
Services = True
Section = "All"
.EXAMPLE
PS C:\PSScript > .\ADDS_Inventory_V2.ps1 -ADForest corp.carlwebster.com
-SmtpServer mail.domain.tld
-From [email protected]
-ComputerName Server01
Will use all Default values.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Carl
Webster" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Carl Webster"
$env:username = Administrator
Carl Webster for the Company Name.
Sideline for the Cover Page format.
Administrator for the User Name.
corp.carlwebster.com for the AD Forest.
The script will be run remotely against server Server01.
The script will use the email server mail.domain.tld, sending from [email protected],
sending to [email protected].
The script will use the default SMTP port 25 and will not use SSL.
If the current user's credentials are not valid to send email,
the user will be prompted to enter valid credentials.
.EXAMPLE
PS C:\PSScript > .\ADDS_Inventory_V2.ps1
-SmtpServer mailrelay.domain.tld
-From [email protected]
***SENDING UNAUTHENTICATED EMAIL***
The script will use the email server mailrelay.domain.tld, sending from
[email protected], sending to [email protected].
To send unauthenticated email using an email relay server requires the From email account
to use the name Anonymous.
The script will use the default SMTP port 25 and will not use SSL.
***GMAIL/G SUITE SMTP RELAY***
https://support.google.com/a/answer/2956491?hl=en
https://support.google.com/a/answer/176600?hl=en
To send email using a Gmail or g-suite account, you may have to turn ON
the "Less secure app access" option on your account.
***GMAIL/G SUITE SMTP RELAY***
The script will generate an anonymous secure password for the [email protected]
account.
.EXAMPLE
PS C:\PSScript > .\ADDS_Inventory_V2.ps1
-SmtpServer labaddomain-com.mail.protection.outlook.com
-UseSSL
-From [email protected]
***OFFICE 365 Example***
https://docs.microsoft.com/en-us/exchange/mail-flow-best-practices/how-to-set-up-a-multifunction-device-or-application-to-send-email-using-office-3
This uses Option 2 from the above link.
***OFFICE 365 Example***
The script will use the email server labaddomain-com.mail.protection.outlook.com,
sending from [email protected], sending to [email protected].
The script will use the default SMTP port 25 and will use SSL.
.EXAMPLE
PS C:\PSScript > .\ADDS_Inventory_V2.ps1
-SmtpServer smtp.office365.com
-SmtpPort 587
-UseSSL
-From [email protected]
The script will use the email server smtp.office365.com on port 587 using SSL,
sending from [email protected], sending to [email protected].
If the current user's credentials are not valid to send email,
the user will be prompted to enter valid credentials.
.EXAMPLE
PS C:\PSScript > .\ADDS_Inventory_V2.ps1
-SmtpServer smtp.gmail.com
-SmtpPort 587
-UseSSL
-From [email protected]
*** NOTE ***
To send email using a Gmail or g-suite account, you may have to turn ON
the "Less secure app access" option on your account.
*** NOTE ***
The script will use the email server smtp.gmail.com on port 587 using SSL,
sending from [email protected], sending to [email protected].
If the current user's credentials are not valid to send email,
the user will be prompted to enter valid credentials.
.INPUTS
None. You cannot pipe objects to this script.
.OUTPUTS
No objects are output from this script. This script creates a Word or PDF document.
.NOTES
NAME: ADDS_Inventory_V2.ps1
VERSION: 2.26
AUTHOR: Carl Webster and Michael B. Smith
LASTEDIT: May 8, 2020
#>
#thanks to @jeffwouters and Michael B. Smith for helping me with these parameters
[CmdletBinding(SupportsShouldProcess = $False, ConfirmImpact = "None", DefaultParameterSetName = "Word") ]
Param(
[parameter(ParameterSetName="HTML",Mandatory=$False)]
[Switch]$HTML=$False,
[parameter(ParameterSetName="Word",Mandatory=$False)]
[Switch]$MSWord=$False,
[parameter(ParameterSetName="PDF",Mandatory=$False)]
[Switch]$PDF=$False,
[parameter(ParameterSetName="Text",Mandatory=$False)]
[Switch]$Text=$False,
[parameter(Mandatory=$False)]
[Switch]$AddDateTime=$False,
[parameter(Mandatory=$False)]
[string]$ADDomain="",
[parameter(Mandatory=$False)]
[string]$ADForest=$Env:USERDNSDOMAIN,
[parameter(ParameterSetName="Word",Mandatory=$False)]
[parameter(ParameterSetName="PDF",Mandatory=$False)]
[Alias("CA")]
[ValidateNotNullOrEmpty()]
[string]$CompanyAddress="",
[parameter(ParameterSetName="Word",Mandatory=$False)]
[parameter(ParameterSetName="PDF",Mandatory=$False)]
[Alias("CE")]
[ValidateNotNullOrEmpty()]
[string]$CompanyEmail="",
[parameter(ParameterSetName="Word",Mandatory=$False)]
[parameter(ParameterSetName="PDF",Mandatory=$False)]
[Alias("CF")]
[ValidateNotNullOrEmpty()]
[string]$CompanyFax="",
[parameter(ParameterSetName="Word",Mandatory=$False)]
[parameter(ParameterSetName="PDF",Mandatory=$False)]
[Alias("CN")]
[ValidateNotNullOrEmpty()]
[string]$CompanyName="",
[parameter(ParameterSetName="Word",Mandatory=$False)]
[parameter(ParameterSetName="PDF",Mandatory=$False)]
[Alias("CPh")]
[ValidateNotNullOrEmpty()]
[string]$CompanyPhone="",
[parameter(Mandatory=$False)]
[Alias("ServerName")]
[string]$ComputerName=$Env:USERDNSDOMAIN,
[parameter(ParameterSetName="Word",Mandatory=$False)]
[parameter(ParameterSetName="PDF",Mandatory=$False)]
[Alias("CP")]
[ValidateNotNullOrEmpty()]
[string]$CoverPage="Sideline",
[parameter(Mandatory=$False)]
[Switch]$DCDNSInfo=$False,
[parameter(Mandatory=$False)]
[Switch]$Dev=$False,
[parameter(Mandatory=$False)]
[string]$Folder="",
[parameter(Mandatory=$False)]
[Switch]$GPOInheritance=$False,
[parameter(Mandatory=$False)]
[Switch]$Hardware=$False,
[parameter(Mandatory=$False)]
[Alias("IU")]
[Switch]$IncludeUserInfo=$False,
[parameter(Mandatory=$False)]
[Switch]$Log=$False,
[parameter(Mandatory=$False)]
[Alias("MAX")]
[Switch]$MaxDetails=$False,
[parameter(Mandatory=$False)]
[Alias("SI")]
[Switch]$ScriptInfo=$False,
[parameter(Mandatory=$False)]
[array]$Section="All",
[parameter(Mandatory=$False )]
[Switch]$Services=$False,
[parameter(ParameterSetName="Word",Mandatory=$False)]
[parameter(ParameterSetName="PDF",Mandatory=$False)]
[Alias("UN")]
[ValidateNotNullOrEmpty()]
[string]$UserName=$env:username,
[parameter(Mandatory=$False)]
[string]$SmtpServer="",
[parameter(Mandatory=$False)]
[int]$SmtpPort=25,
[parameter(Mandatory=$False)]
[switch]$UseSSL=$False,
[parameter(Mandatory=$False)]
[string]$From="",
[parameter(Mandatory=$False)]
[string]$To=""
)
#Created by Carl Webster and Michael B. Smith
#@carlwebster on Twitter
#https://www.CarlWebster.com
#
#@essentialexch on Twitter
#https://www.essential.exchange/blog/
#
#Created on April 10, 2014
#Version 1.0 released to the community on May 31, 2014
#
#Version 2.0 is based on version 1.20