-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDocu-FAS.ps1
6863 lines (6096 loc) · 213 KB
/
Docu-FAS.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
#This File is in Unicode format. Do not edit in an ASCII editor. Notepad++ UTF-8-BOM
#region help text
<#
.SYNOPSIS
Creates an inventory of Citrix Federated Authentication Service.
.DESCRIPTION
Creates an inventory of Citrix Federated Authentication Service using Microsoft
PowerShell, Word, plain text, or HTML.
This Script requires at least PowerShell version 3.
This script requires an elevated PowerShell session.
Word is NOT needed to run the script. This script outputs in Text and HTML.
The default output format is HTML.
Creates an output file named CitrixFASInventory.<fileextension>.
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-add
Dutch
English
Finnish
French
German
Norwegian
Portuguese
Spanish
Swedish
.PARAMETER HTML
Creates an HTML file with an .html extension.
HTML is now the default report format.
This parameter is set True if no other output format is selected.
.PARAMETER Text
Creates a formatted text file with a .txt extension.
This parameter is disabled by default.
.PARAMETER AddDateTime
Adds a date timestamp to the end of the file name.
The timestamp is in the format of yyyy-MM-dd_HHmm.
June 1, 2021 at 6PM is 2021-06-01_1800.
Output filename will be ReportName_2021-06-01_1800.<fileextension>.
This parameter is disabled by default.
This parameter has an alias of ADT.
.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 Hardware
Use WMI to gather hardware information on Computer System, Disks, Processor, and
Network Interface Cards for the Certificate Authority server(s) and the FAS
server(s).
This parameter may require using an account with permission to retrieve hardware
information (i.e. Domain Admin or Local Administrator, this includes Local
Administrator on the Certificate Authority server(s)).
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.
This parameter has an alias of HW.
.PARAMETER Log
Generates a log file for troubleshooting.
.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 CitrixTemplatesOnly
When processing the Microsoft certificate templates, only process the templates
with Citrix in the template name.
If you make a copy of a Citrix template and do not include "Citrix" in the
template name, that template is not included.
This parameter is disabled by default.
This parameter has an alias of CTO.
.PARAMETER LimitUserCertificates
Use this parameter to limit the number of FAS user certificates included in the
report.
By default, this is set to [int]::MaxValue which is 2,147,483,647.
This parameter has an alias of LUC.
.PARAMETER MSWord
SaveAs DOCX file
Microsoft Word is no longer the default report format.
This parameter is disabled by default.
.PARAMETER PDF
SaveAs PDF file instead of DOCX file.
The PDF file is roughly 5X to 10X larger than the DOCX file.
This parameter requires Microsoft Word to be installed.
This parameter uses Word's SaveAs PDF capability.
This parameter is disabled by default.
.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.
The 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 is only valid with the MSWORD and PDF output parameters.
This parameter has an alias of CN.
.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 UserName
Username to use for the Cover Page and Footer.
The 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 SmtpPort
Specifies the SMTP port for the SmtpServer.
The default is 25.
.PARAMETER SmtpServer
Specifies the optional email server to send the output report(s).
If From or To are used, this is a required parameter.
.PARAMETER From
Specifies the username for the From email address.
If SmtpServer or To are used, this is a required parameter.
.PARAMETER To
Specifies the username for the To email address.
If SmtpServer or From are used, this is a required parameter.
.PARAMETER UseSSL
Specifies whether to use SSL for the SmtpServer.
The default is False.
.EXAMPLE
PS C:\PSScript > .\Docu-FAS.ps1
Creates an HTML report.
.EXAMPLE
PS C:\PSScript > .\Docu-FAS.ps1 -PDF
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.
The computer running the script for the AdminAddress.
.EXAMPLE
PS C:\PSScript > .\Docu-FAS.ps1 -TEXT
Creates a text report.
.EXAMPLE
PS C:\PSScript > .\Docu-FAS.ps1 -HTML
Creates an HTML report.
.EXAMPLE
PS C:\PSScript > .\Docu-FAS.ps1 -HTML -MSWord -PDF -Text
Creates four reports. One each in HTML, Microsoft Word, PDF, and plain text.
.EXAMPLE
PS C:\PSScript .\Docu-FAS.ps1 -MSWord -CompanyName "Carl Webster
Consulting" -CoverPage "Mod" -UserName "Carl Webster"
Will use:
Carl Webster Consulting for the Company Name.
Mod for the Cover Page format.
Carl Webster for the User Name.
.EXAMPLE
PS C:\PSScript .\Docu-FAS.ps1 -MSWord -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).
The computer running the script for the AdminAddress.
.EXAMPLE
PS C:\PSScript .\Docu-FAS.ps1 -MSWord
-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.
.EXAMPLE
PS C:\PSScript .\Docu-FAS.ps1 -MSWord
-CompanyName "Sherlock Holmes Consulting"
-CoverPage Facet
-UserName "Dr. Watson"
-CompanyEmail SuperSleuth@SherlockHolmes.com
Will use:
Sherlock Holmes Consulting for the Company Name.
Facet for the Cover Page format.
Dr. Watson for the User Name.
SuperSleuth@SherlockHolmes.com for the Company Email.
.EXAMPLE
PS C:\PSScript > .\Docu-FAS.ps1 -AddDateTime
Creates an HTML file.
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 CitrixFASInventory_2020-06-01_1800.html.
.EXAMPLE
PS C:\PSScript > .\Docu-FAS.ps1 -PDF -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.
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 CitrixFASInventory_2020-06-01_1800.pdf.
.EXAMPLE
PS C:\PSScript > .\Docu-FAS.ps1 -Folder \\FileServer\ShareName
HTML output file will be saved in the path \\FileServer\ShareName
.EXAMPLE
PS C:\PSScript > .\Docu-FAS.ps1 -Dev -ScriptInfo -Log
Creates an HTML file.
Creates a text file named FASV1InventoryScriptErrors_yyyy-MM-dd_HHmm.txt that
contains up to the last 250 errors reported by the script.
Creates a text file named FASV1InventoryScriptInfo_yyyy-MM-dd_HHmm.txt that
contains all the script parameters and other basic information.
Creates a text file for transcript logging named
FASV1DocScriptTranscript_yyyy-MM-dd_HHmm.txt.
.EXAMPLE
PS C:\PSScript > .\Docu-FAS.ps1 -CitrixTemplatesOnly
Creates an HTML report.
Includes only certificate templates with "Citrix" in the name.
.EXAMPLE
PS C:\PSScript > .\Docu-FAS.ps1 -LimitUserCertificates 25
Creates an HTML report.
Includes up to the first 25 user certificates.
.EXAMPLE
PS C:\PSScript > .\Docu-FAS.ps1
-SmtpServer mail.domain.tld
-From XDAdmin@domain.tld
-To ITGroup@domain.tld
The script will use the email server mail.domain.tld, sending from XDAdmin@domain.tld,
sending to ITGroup@domain.tld.
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 > .\Docu-FAS.ps1
-SmtpServer mailrelay.domain.tld
-From Anonymous@domain.tld
-To ITGroup@domain.tld
***SENDING UNAUTHENTICATED EMAIL***
The script will use the email server mailrelay.domain.tld, sending from
anonymous@domain.tld, sending to ITGroup@domain.tld.
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 anonymous@domain.tld
account.
.EXAMPLE
PS C:\PSScript > .\Docu-FAS.ps1
-SmtpServer labaddomain-com.mail.protection.outlook.com
-UseSSL
-From SomeEmailAddress@labaddomain.com
-To ITGroupDL@labaddomain.com
***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 SomeEmailAddress@labaddomain.com, sending to ITGroupDL@labaddomain.com.
The script will use the default SMTP port 25 and will use SSL.
.EXAMPLE
PS C:\PSScript > .\Docu-FAS.ps1
-SmtpServer smtp.office365.com
-SmtpPort 587
-UseSSL
-From Webster@CarlWebster.com
-To ITGroup@CarlWebster.com
The script will use the email server smtp.office365.com on port 587 using SSL,
sending from webster@carlwebster.com, sending to ITGroup@carlwebster.com.
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 > .\Docu-FAS.ps1
-SmtpServer smtp.gmail.com
-SmtpPort 587
-UseSSL
-From Webster@CarlWebster.com
-To ITGroup@CarlWebster.com
*** 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 webster@gmail.com, sending to ITGroup@carlwebster.com.
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, PDF, plain text, or HTML document.
.NOTES
NAME: Docu-FAS.ps1
VERSION: 1.12
AUTHOR: Carl Webster and Michael B. Smith
LASTEDIT: January 10, 2021
#>
#endregion
#region script parameters
#thanks to Michael B. Smith for helping me with these parameters
[CmdletBinding(SupportsShouldProcess = $False, ConfirmImpact = "None", DefaultParameterSetName = "") ]
Param(
[parameter(Mandatory=$False)]
[Switch]$HTML=$False,
[parameter(Mandatory=$False)]
[Switch]$Text=$False,
[parameter(Mandatory=$False)]
[Alias("ADT")]
[Switch]$AddDateTime=$False,
[parameter(Mandatory=$False)]
[Switch]$Dev=$False,
[parameter(Mandatory=$False)]
[string]$Folder="",
[parameter(Mandatory=$False)]
[Alias("HW")]
[Switch]$Hardware=$False,
[parameter(Mandatory=$False)]
[Switch]$Log=$False,
[parameter(Mandatory=$False)]
[Alias("SI")]
[Switch]$ScriptInfo=$False,
[parameter(Mandatory=$False)]
[Alias("CTO")]
[Switch]$CitrixTemplatesOnly=$False,
[parameter(Mandatory=$False)]
[Alias("LUC")]
[Int]$LimitUserCertificates=[int]::MaxValue,
[parameter(ParameterSetName="WordPDF",Mandatory=$False)]
[Switch]$MSWord=$False,
[parameter(ParameterSetName="WordPDF",Mandatory=$False)]
[Switch]$PDF=$False,
[parameter(ParameterSetName="WordPDF",Mandatory=$False)]
[Alias("CA")]
[ValidateNotNullOrEmpty()]
[string]$CompanyAddress="",
[parameter(ParameterSetName="WordPDF",Mandatory=$False)]
[Alias("CE")]
[ValidateNotNullOrEmpty()]
[string]$CompanyEmail="",
[parameter(ParameterSetName="WordPDF",Mandatory=$False)]
[Alias("CF")]
[ValidateNotNullOrEmpty()]
[string]$CompanyFax="",
[parameter(ParameterSetName="WordPDF",Mandatory=$False)]
[Alias("CN")]
[ValidateNotNullOrEmpty()]
[string]$CompanyName="",
[parameter(ParameterSetName="WordPDF",Mandatory=$False)]
[Alias("CPh")]
[ValidateNotNullOrEmpty()]
[string]$CompanyPhone="",
[parameter(ParameterSetName="WordPDF",Mandatory=$False)]
[Alias("CP")]
[ValidateNotNullOrEmpty()]
[string]$CoverPage="Sideline",
[parameter(ParameterSetName="WordPDF",Mandatory=$False)]
[Alias("UN")]
[ValidateNotNullOrEmpty()]
[string]$UserName=$env:username,
[parameter(Mandatory=$False)]
[int]$SmtpPort=25,
[parameter(Mandatory=$False)]
[string]$SmtpServer="",
[parameter(Mandatory=$False)]
[string]$From="",
[parameter(Mandatory=$False)]
[string]$To="",
[parameter(Mandatory=$False)]
[switch]$UseSSL=$False
)
#endregion
#region script change log
#webster@carlwebster.com
#@carlwebster on Twitter
#http://www.CarlWebster.com
#Created on March 31, 2019
#
#Version 1.12
# Added to the Computer Hardware section, the server's Power Plan
# Changed all Write-Verbose statements from Get-Date to Get-Date -Format G as requested by Guy Leech
# Reordered parameters in an order recommended by Guy Leech
# Updated help text
# Updated ReadMe file
#
#Version 1.11 9-May-2020
# Add checking for a Word version of 0, which indicates the Office installation needs repairing
# Add Receive Side Scaling setting to Function OutputNICItem
# Change color variables $wdColorGray15 and $wdColorGray05 from [long] to [int]
# Change location of the -Dev, -Log, and -ScriptInfo output files from the script folder to the -Folder location (Thanks to Guy Leech for the "suggestion")
# Update Function SendEmail to handle anonymous unauthenticated email
# Update Function SetWordCellFormat to change parameter $BackgroundColor to [int]
# Update Functions GetComputerWMIInfo and OutputNicInfo to fix two bugs in NIC Power Management settings
# Update Help Text
#
#Version 1.10 10-Feb-2020
# Added new section for Local Administration Policy
# Added new section for Private Key Pool Info
# Added to FAS Server Information, the Capabilities property
# Fixed several alignment issues in the Text output option
# Fixed Swedish Table of Contents (Thanks to Johan Kallio)
# From
# 'sv-' { 'Automatisk innehållsförteckning2'; Break }
# To
# 'sv-' { 'Automatisk innehållsförteckn2'; Break }
#
#Version 1.01 18-May-2019
# Fix some typos in the help text and remove some unneeded comments
#
# Version 1.0 released to the community on May 13, 2019
#
#endregion
#region initial variable testing and setup
Set-StrictMode -Version Latest
#force on
$PSDefaultParameterValues = @{"*:Verbose"=$True}
$Script:emailCredentials = $Null
function wv
{
$s = $args -join ''
Write-Verbose $s
}
If($MSWord -eq $False -and $PDF -eq $False -and $Text -eq $False -and $HTML -eq $False)
{
$HTML = $True
}
If($MSWord)
{
Write-Verbose "$(Get-Date -Format G): MSWord is set"
}
If($PDF)
{
Write-Verbose "$(Get-Date -Format G): PDF is set"
}
If($Text)
{
Write-Verbose "$(Get-Date -Format G): Text is set"
}
If($HTML)
{
Write-Verbose "$(Get-Date -Format G): HTML is set"
}
If($Folder -ne "")
{
Write-Verbose "$(Get-Date -Format G): Testing folder path"
#does it exist
If(Test-Path $Folder -EA 0)
{
#it exists, now check to see if it is a folder and not a file
If(Test-Path $Folder -pathType Container -EA 0)
{
#it exists and it is a folder
Write-Verbose "$(Get-Date -Format G): Folder path $Folder exists and is a folder"
}
Else
{
#it exists but it is a file not a folder
Write-Error "
`n`n
`t`t
Folder $Folder is a file, not a folder.
`n`n
`t`t
Script cannot continue.
`n`n
"
AbortScript
}
}
Else
{
#does not exist
Write-Error "
`n`n
`t`t
Folder $Folder does not exist.
`n`n
`t`t
Script cannot continue.
`n`n
"
AbortScript
}
}
If($Folder -eq "")
{
$Script:pwdpath = $pwd.Path
}
Else
{
$Script:pwdpath = $Folder
}
If($Script:pwdpath.EndsWith("\"))
{
#remove the trailing \
$Script:pwdpath = $Script:pwdpath.SubString(0, ($Script:pwdpath.Length - 1))
}
If($Log)
{
#start transcript logging
$Script:LogPath = "$Script:pwdpath\FASV1DocScriptTranscript_$(Get-Date -f yyyy-MM-dd_HHmm).txt"
try
{
Start-Transcript -Path $Script:LogPath -Force -Verbose:$false | Out-Null
Write-Verbose "$(Get-Date -Format G): Transcript/log started at $Script:LogPath"
$Script:StartLog = $true
}
catch
{
Write-Verbose "$(Get-Date -Format G): Transcript/log failed at $Script:LogPath"
$Script:StartLog = $false
}
}
If($Dev)
{
$Error.Clear()
$Script:DevErrorFile = "$Script:pwdpath\FASV1InventoryScriptErrors_$(Get-Date -f yyyy-MM-dd_HHmm).txt"
}
If(![String]::IsNullOrEmpty($SmtpServer) -and [String]::IsNullOrEmpty($From) -and [String]::IsNullOrEmpty($To))
{
Write-Error "
`n`n
`t`t
You specified an SmtpServer but did not include a From or To email address.
`n`n
`t`t
Script cannot continue.
`n`n"
Exit
}
If(![String]::IsNullOrEmpty($SmtpServer) -and [String]::IsNullOrEmpty($From) -and ![String]::IsNullOrEmpty($To))
{
Write-Error "
`n`n
`t`t
You specified an SmtpServer and a To email address but did not include a From email address.
`n`n
`t`t
Script cannot continue.
`n`n"
Exit
}
If(![String]::IsNullOrEmpty($SmtpServer) -and [String]::IsNullOrEmpty($To) -and ![String]::IsNullOrEmpty($From))
{
Write-Error "
`n`n
`t`t
You specified an SmtpServer and a From email address but did not include a To email address.
`n`n
`t`t
Script cannot continue.
`n`n"
Exit
}
If(![String]::IsNullOrEmpty($From) -and ![String]::IsNullOrEmpty($To) -and [String]::IsNullOrEmpty($SmtpServer))
{
Write-Error "
`n`n
`t`t
You specified From and To email addresses but did not include the SmtpServer.
`n`n
`t`t
Script cannot continue.
`n`n"
Exit
}
If(![String]::IsNullOrEmpty($From) -and [String]::IsNullOrEmpty($SmtpServer))
{
Write-Error "
`n`n
`t`t
You specified a From email address but did not include the SmtpServer.
`n`n
`t`t
Script cannot continue.
`n`n"
Exit
}
If(![String]::IsNullOrEmpty($To) -and [String]::IsNullOrEmpty($SmtpServer))
{
Write-Error "
`n`n
`t`t
You specified a To email address but did not include the SmtpServer.
`n`n
`t`t
Script cannot continue.
`n`n"
Exit
}
#endregion
#region initialize variables for Word, HTML, and text
[string]$Script:RunningOS = (Get-WmiObject -class Win32_OperatingSystem -EA 0).Caption
If($MSWord -or $PDF)
{
#the following values were attained from
#http://groovy.codehaus.org/modules/scriptom/1.6.0/scriptom-office-2K3-tlb/apidocs/
#http://msdn.microsoft.com/en-us/library/office/aa211923(v=office.11).aspx
[int]$wdAlignPageNumberRight = 2
[int]$wdColorGray15 = 14277081
[int]$wdColorGray05 = 15987699
[int]$wdMove = 0
[int]$wdSeekMainDocument = 0
[int]$wdSeekPrimaryFooter = 4
[int]$wdStory = 6
[int]$wdColorRed = 255
[int]$wdColorBlack = 0
[int]$wdWord2007 = 12
[int]$wdWord2010 = 14
[int]$wdWord2013 = 15
[int]$wdWord2016 = 16
[int]$wdFormatDocumentDefault = 16
[int]$wdFormatPDF = 17
#http://blogs.technet.com/b/heyscriptingguy/archive/2006/03/01/how-can-i-right-align-a-single-column-in-a-word-table.aspx
#http://msdn.microsoft.com/en-us/library/office/ff835817%28v=office.15%29.aspx
#[int]$wdAlignParagraphLeft = 0
#[int]$wdAlignParagraphCenter = 1
#[int]$wdAlignParagraphRight = 2
#http://msdn.microsoft.com/en-us/library/office/ff193345%28v=office.15%29.aspx
#[int]$wdCellAlignVerticalTop = 0
#[int]$wdCellAlignVerticalCenter = 1
#[int]$wdCellAlignVerticalBottom = 2
#http://msdn.microsoft.com/en-us/library/office/ff844856%28v=office.15%29.aspx
[int]$wdAutoFitFixed = 0
[int]$wdAutoFitContent = 1
#[int]$wdAutoFitWindow = 2
#http://msdn.microsoft.com/en-us/library/office/ff821928%28v=office.15%29.aspx
[int]$wdAdjustNone = 0
[int]$wdAdjustProportional = 1
#[int]$wdAdjustFirstColumn = 2
#[int]$wdAdjustSameWidth = 3
[int]$PointsPerTabStop = 36
[int]$Indent0TabStops = 0 * $PointsPerTabStop
#[int]$Indent1TabStops = 1 * $PointsPerTabStop
#[int]$Indent2TabStops = 2 * $PointsPerTabStop
#[int]$Indent3TabStops = 3 * $PointsPerTabStop
#[int]$Indent4TabStops = 4 * $PointsPerTabStop
# http://www.thedoctools.com/index.php?show=wt_style_names_english_danish_german_french
[int]$wdStyleHeading1 = -2
[int]$wdStyleHeading2 = -3
[int]$wdStyleHeading3 = -4
[int]$wdStyleHeading4 = -5
[int]$wdStyleNoSpacing = -158
[int]$wdTableGrid = -155
[int]$wdTableLightListAccent3 = -206
#http://groovy.codehaus.org/modules/scriptom/1.6.0/scriptom-office-2K3-tlb/apidocs/org/codehaus/groovy/scriptom/tlb/office/word/WdLineStyle.html
[int]$wdLineStyleNone = 0
[int]$wdLineStyleSingle = 1
[int]$wdHeadingFormatTrue = -1
#[int]$wdHeadingFormatFalse = 0
}
If($HTML)
{
$Script:htmlredmask = "#FF0000" 4>$Null
$Script:htmlcyanmask = "#00FFFF" 4>$Null
$Script:htmlbluemask = "#0000FF" 4>$Null
$Script:htmldarkbluemask = "#0000A0" 4>$Null
$Script:htmllightbluemask = "#ADD8E6" 4>$Null
$Script:htmlpurplemask = "#800080" 4>$Null
$Script:htmlyellowmask = "#FFFF00" 4>$Null
$Script:htmllimemask = "#00FF00" 4>$Null
$Script:htmlmagentamask = "#FF00FF" 4>$Null
$Script:htmlwhitemask = "#FFFFFF" 4>$Null
$Script:htmlsilvermask = "#C0C0C0" 4>$Null
$Script:htmlgraymask = "#808080" 4>$Null
$Script:htmlblackmask = "#000000" 4>$Null
$Script:htmlorangemask = "#FFA500" 4>$Null
$Script:htmlmaroonmask = "#800000" 4>$Null
$Script:htmlgreenmask = "#008000" 4>$Null
$Script:htmlolivemask = "#808000" 4>$Null
$Script:htmlbold = 1 4>$Null
$Script:htmlitalics = 2 4>$Null
$Script:htmlred = 4 4>$Null
$Script:htmlcyan = 8 4>$Null
$Script:htmlblue = 16 4>$Null
$Script:htmldarkblue = 32 4>$Null
$Script:htmllightblue = 64 4>$Null
$Script:htmlpurple = 128 4>$Null
$Script:htmlyellow = 256 4>$Null
$Script:htmllime = 512 4>$Null
$Script:htmlmagenta = 1024 4>$Null
$Script:htmlwhite = 2048 4>$Null
$Script:htmlsilver = 4096 4>$Null
$Script:htmlgray = 8192 4>$Null
$Script:htmlolive = 16384 4>$Null
$Script:htmlorange = 32768 4>$Null
$Script:htmlmaroon = 65536 4>$Null
$Script:htmlgreen = 131072 4>$Null
$Script:htmlblack = 262144 4>$Null
$Script:htmlsb = ( $htmlsilver -bor $htmlBold ) ## point optimization
$Script:htmlColor =
@{
$htmlred = $htmlredmask
$htmlcyan = $htmlcyanmask
$htmlblue = $htmlbluemask
$htmldarkblue = $htmldarkbluemask
$htmllightblue = $htmllightbluemask
$htmlpurple = $htmlpurplemask
$htmlyellow = $htmlyellowmask
$htmllime = $htmllimemask
$htmlmagenta = $htmlmagentamask
$htmlwhite = $htmlwhitemask
$htmlsilver = $htmlsilvermask
$htmlgray = $htmlgraymask
$htmlolive = $htmlolivemask
$htmlorange = $htmlorangemask
$htmlmaroon = $htmlmaroonmask
$htmlgreen = $htmlgreenmask
$htmlblack = $htmlblackmask
}
}
#endregion
#region code for hardware data
Function GetComputerWMIInfo
{
Param([string]$RemoteComputerName)
# original work by Kees Baggerman,
# Senior Technical Consultant @ Inter Access
# k.baggerman@myvirtualvision.com
# @kbaggerman on Twitter
# http://blog.myvirtualvision.com
# modified 1-May-2014 to work in trusted AD Forests and using different domain admin credentials
# modified 17-Aug-2016 to fix a few issues with Text and HTML output
# modified 29-Apr-2018 to change from Arrays to New-Object System.Collections.ArrayList
#Get Computer info
Write-Verbose "$(Get-Date -Format G): `t`tProcessing WMI Computer information"
Write-Verbose "$(Get-Date -Format G): `t`t`tHardware information"
If($MSWord -or $PDF)
{
WriteWordLine 3 0 "Computer Information: $($RemoteComputerName)"
WriteWordLine 4 0 "General Computer"
}
If($Text)
{
Line 0 "Computer Information: $($RemoteComputerName)"
Line 1 "General Computer"
}
If($HTML)
{
WriteHTMLLine 3 0 "Computer Information: $($RemoteComputerName)"
WriteHTMLLine 4 0 "General Computer"
}
Try
{
$Results = Get-WmiObject -computername $RemoteComputerName win32_computersystem
}
Catch
{
$Results = $Null
}
If($? -and $Null -ne $Results)
{
$ComputerItems = $Results | Select-Object Manufacturer, Model, Domain, `
@{N="TotalPhysicalRam"; E={[math]::round(($_.TotalPhysicalMemory / 1GB),0)}}, `
NumberOfProcessors, NumberOfLogicalProcessors
$Results = $Null
[string]$ComputerOS = (Get-WmiObject -class Win32_OperatingSystem -computername $RemoteComputerName -EA 0).Caption
ForEach($Item in $ComputerItems)
{
OutputComputerItem $Item $ComputerOS $RemoteComputerName
}
}
ElseIf(!$?)
{
Write-Verbose "$(Get-Date -Format G): Get-WmiObject win32_computersystem failed for $($RemoteComputerName)"
Write-Warning "Get-WmiObject win32_computersystem failed for $($RemoteComputerName)"
If($MSWORD -or $PDF)
{
WriteWordLine 0 2 "Get-WmiObject win32_computersystem failed for $($RemoteComputerName)" "" $Null 0 $False $True
WriteWordLine 0 2 "On $($RemoteComputerName) you may need to run winmgmt /verifyrepository" "" $Null 0 $False $True
WriteWordLine 0 2 "and winmgmt /salvagerepository. If this is a trusted Forest, you may" "" $Null 0 $False $True
WriteWordLine 0 2 "need to rerun the script with Domain Admin credentials from the trusted Forest." "" $Null 0 $False $True
}
If($Text)
{
Line 2 "Get-WmiObject win32_computersystem failed for $($RemoteComputerName)"