-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNetScaler_Script_v2_5_unsigned.txt
7481 lines (6523 loc) · 294 KB
/
NetScaler_Script_v2_5_unsigned.txt
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.
#region Support
<#
.SYNOPSIS
Creates a complete inventory of a Citrix NetScaler configuration using Microsoft Word.
.DESCRIPTION
Creates a complete inventory of a Citrix NetScaler configuration using Microsoft Word and PowerShell.
Creates a Word document named after the Citrix NetScaler Configuration.
Document includes a Cover Page, Table of Contents and Footer.
Includes support for the following language versions of Microsoft Word:
Catalan
Danish
Dutch
English
Finnish
French
German
Norwegian
Portuguese
Spanish
Swedish
.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.
.PARAMETER CoverPage
What Microsoft Word Cover Page to use.
(default cover pages in Word en-US)
Valid input is:
Alphabet (Word 2007/2010. Works)
Annual (Word 2007/2010. Doesn't work well for this report)
Austere (Word 2007/2010. Works)
Austin (Word 2007/2010/2013. Doesn't work in 2013, mostly works in 2007/2010 but Subtitle/Subject & Author fields need to me moved after title box is moved up)
Banded (Word 2013. Works)
Conservative (Word 2007/2010. Works)
Contrast (Word 2007/2010. Works)
Cubicles (Word 2007/2010. Works)
Exposure (Word 2007/2010. Works if you like looking sideways)
Facet (Word 2013. Works)
Filigree (Word 2013. Works)
Grid (Word 2010/2013.Works in 2010)
Integral (Word 2013. Works)
Ion (Dark) (Word 2013. Top date doesn't fit, box needs to be manually resized or font changed to 8 point)
Ion (Light) (Word 2013. Top date doesn't fit, box needs to be manually resized or font changed to 8 point)
Mod (Word 2007/2010. Works)
Motion (Word 2007/2010/2013. 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 2007/2010. Works)
Puzzle (Word 2007/2010. Top date doesn't fit, box needs to be manually resized or font changed to 14 point)
Retrospect (Word 2013. Works)
Semaphore (Word 2013. Works)
Sideline (Word 2007/2010/2013. Doesn't work in 2013, works in 2007/2010)
Slice (Dark) (Word 2013. Doesn't work)
Slice (Light) (Word 2013. Doesn't work)
Stacks (Word 2007/2010. Works)
Tiles (Word 2007/2010. Date doesn't fit unless changed to 26 point)
Transcend (Word 2007/2010. Works)
ViewMaster (Word 2013. Works)
Whisp (Word 2013. Works)
Default value is Sideline.
This parameter has an alias of CP.
.PARAMETER UserName
User name to use for the Cover Page and Footer.
Default value is contained in $env:username
This parameter has an alias of UN.
.PARAMETER PDF
SaveAs PDF file instead of DOCX file.
This parameter is disabled by default.
For Word 2007, the Microsoft add-in for saving as a PDF muct be installed.
For Word 2007, please see http://www.microsoft.com/en-us/download/details.aspx?id=9943
The PDF file is roughly 5X to 10X larger than the DOCX file.
.PARAMETER Text
Creates a formatted text file with a .txt extension.
This parameter is disabled by default.
This parameter is reserved for a future update and no output is created at this time.
.PARAMETER MSWord
SaveAs DOCX file
This parameter is set True if no other output format is selected.
.PARAMETER HTML
Creates an HTML file with an .html extension.
This parameter is disabled by default.
This parameter is reserved for a future update and no output is created at this time.
.PARAMETER AddDateTime
Adds a date time stamp to the end of the file name.
Time stamp is in the format of yyyy-MM-dd_HHmm.
June 1, 2014 at 6PM is 2014-06-01_1800.
Output filename will be ReportName_2014-06-01_1800.docx (or .pdf).
This parameter is disabled by default.
.PARAMETER Hardware
Use WMI to gather hardware information on: Computer System, Disks, Processor and Network Interface Cards
This parameter may require the script be run from an elevated PowerShell session
using an account with permission to retrieve hardware information (i.e. Domain Admin or Local Administrator).
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 ComputerName
Specifies a computer to use to run the script against.
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.
Default is localhost.
.EXAMPLE
PS C:\PSScript > .\NetScaler_Script_v2_5.ps1
Will use all default values.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Barry Schiffer" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Barry Schiffer"
$env:username = Administrator
Barry Schiffer for the Company Name.
Sideline for the Cover Page format.
Administrator for the User Name.
.EXAMPLE
PS C:\PSScript > .\NetScaler_Script_v2_5.ps1 -PDF
Will use all default values and save the document as a PDF file.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Barry Schiffer" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Barry Schiffer"
$env:username = Administrator
Barry Schiffer for the Company Name.
Sideline for the Cover Page format.
Administrator for the User Name.
.EXAMPLE
PS C:\PSScript > .\NetScaler_Script_v2_5.ps1 -TEXT
Will use all default values and save the document as a formatted text file.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Barry Schiffer" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Barry Schiffer"
$env:username = Administrator
Barry Schiffer for the Company Name.
Sideline for the Cover Page format.
Administrator for the User Name.
.EXAMPLE
PS C:\PSScript > .\NetScaler_Script_v2_5.ps1 -HTML
Will use all default values and save the document as an HTML file.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Barry Schiffer" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Barry Schiffer"
$env:username = Administrator
Barry Schiffer for the Company Name.
Sideline for the Cover Page format.
Administrator for the User Name.
.EXAMPLE
PS C:\PSScript .\NetScaler_Script_v2_5.ps1 -CompanyName "Barry Schiffer Consulting" -CoverPage "Mod" -UserName "Barry Schiffer"
Will use:
Barry Schiffer Consulting for the Company Name.
Mod for the Cover Page format.
Barry Schiffer for the User Name.
.EXAMPLE
PS C:\PSScript .\NetScaler_Script_v2_5.ps1 -CN "Barry Schiffer Consulting" -CP "Mod" -UN "Barry Schiffer"
Will use:
Barry Schiffer Consulting for the Company Name (alias CN).
Mod for the Cover Page format (alias CP).
Barry Schiffer for the User Name (alias UN).
.EXAMPLE
PS C:\PSScript > .\NetScaler_Script_v2_5.ps1 -AddDateTime
Will use all default values.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Barry Schiffer" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Barry Schiffer"
$env:username = Administrator
Barry Schiffer 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.
Time stamp is in the format of yyyy-MM-dd_HHmm.
June 1, 2014 at 6PM is 2014-06-01_1800.
Output filename will be Script_Template_2014-06-01_1800.docx
.EXAMPLE
PS C:\PSScript > .\NetScaler_Script_v2_5.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="Barry Schiffer" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Barry Schiffer"
$env:username = Administrator
Barry Schiffer 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.
Time stamp is in the format of yyyy-MM-dd_HHmm.
June 1, 2014 at 6PM is 2014-06-01_1800.
Output filename will be Script_Template_2014-06-01_1800.PDF
.EXAMPLE
PS C:\PSScript > .\NetScaler_Script_v2_5.ps1 -Hardware
Will use all default values.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Barry Schiffer" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Barry Schiffer"
$env:username = Administrator
Barry Schiffer for the Company Name.
Sideline for the Cover Page format.
Administrator for the User Name.
localhost for running hardware inventory.
localhost will be replaced by the actual computer name.
.EXAMPLE
PS C:\PSScript > .\NetScaler_Script_v2_5.ps1 -Hardware -ComputerName 192.168.1.51
Will use all default values.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Barry Schiffer" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Barry Schiffer"
$env:username = Administrator
Barry Schiffer for the Company Name.
Sideline for the Cover Page format.
Administrator for the User Name.
192.168.1.51 for running hardware inventory.
192.168.1.51 will be replaced by the actual computer name, if possible.
.INPUTS
None. You cannot pipe objects to this script.
.OUTPUTS
No objects are output from this script.
This script creates a Word, PDF, Formatted Text or HTML document.
.NOTES
NAME: NetScaler_Script_v2_5_unsigned.ps1
VERSION: 16122014
AUTHOR: Carl Webster, Michael B. Smith, Iain Brighton, Jeff Wouters, Barry Schiffer
LASTEDIT: December 16, 2014
#>
#endregion Support
#region script template
#thanks to @jeffwouters and Michael B. Smith for helping me with these parameters
[CmdletBinding(SupportsShouldProcess = $False, ConfirmImpact = "None", DefaultParameterSetName = "WordOrPDF") ]
Param(
[parameter(ParameterSetName="WordOrPDF",
Position = 0,
Mandatory=$False )
]
[Alias("CN")]
[ValidateNotNullOrEmpty()]
[string]$CompanyName="",
[parameter(ParameterSetName="WordOrPDF",
Position = 1,
Mandatory=$False )
]
[Alias("CP")]
[ValidateNotNullOrEmpty()]
[string]$CoverPage="Sideline",
[parameter(ParameterSetName="WordOrPDF",
Position = 2,
Mandatory=$False )
]
[Alias("UN")]
[ValidateNotNullOrEmpty()]
[string]$UserName=$env:username,
[parameter(ParameterSetName="WordOrPDF",
Position = 3,
Mandatory=$False )
]
[Switch]$PDF=$False,
[parameter(ParameterSetName="Text",
Position = 4,
Mandatory=$False )
]
[Switch]$Text=$False,
[parameter(ParameterSetName="WordOrPDF",
Position = 4,
Mandatory=$False )
]
[Switch]$MSWord=$False,
[parameter(ParameterSetName="HTML",
Position = 4,
Mandatory=$False )
]
[Switch]$HTML=$False,
[parameter(
Position = 5,
Mandatory=$False )
]
[Switch]$AddDateTime=$False,
[parameter(
Position = 6,
Mandatory=$False )
]
[Switch]$Hardware=$False,
[parameter(
Position = 7,
Mandatory=$False )
]
[string]$ComputerName="LocalHost"
)
#@carlwebster on Twitter
#http://www.CarlWebster.com
#Created on June 1, 2014
<#
.NetScaler Documentation Script
NAME: NetScaler_Script_v2_5.ps1
VERSION NetScaler Script: 2.5
VERSION Script Template: 16122014
AUTHOR NetScaler script: Barry Schiffer
AUTHOR NetScaler script functions: Iain Brighton
AUTHOR Script template: Carl Webster, Michael B. Smith, Iain Brighton, Jeff Wouters
LASTEDIT: December 16, 2014
.Release Notes version 2
Overall
Test group has grown from 5 to 20 people. A lot more testing on a lot more configs has been done.
The result is that I've received a lot of nitty gritty bugs that are now solved. To many to list them all but this release is very very stable.
New Script functionality
New table function that now utilizes native word tables. Looks a lot better and is way faster
Performance improvements; over 500% faster
Better support for multi language Word versions. Will now always utilize cover page and TOC
New NetScaler functionality:
NetScaler Gateway
Global Settings
Virtual Servers settings and policies
Policies Session/Traffic
NetScaler administration users and groups
NetScaler Authentication
Policies LDAP / Radius
Actions Local / RADIUS
Action LDAP more configuration reported and changed table layout
NetScaler Networking
Channels
ACL
NetScaler Cache redirection
Bugfixes
Naming of items with spaces and quotes fixed
Expressions with spaces, quotes, dashes and slashed fixed
Grammatical corrections
Rechecked all settings like enabled/disabled or on/off and corrected when necessary
Time zone not show correctly when in GMT+....
A lot more small items
.Release Notes version 1
Version 1.0 supports the following NetScaler functionality:
NetScaler System Information
Version / NSIP / vLAN
NetScaler Global Settings
NetScaler Feature and mode state
NetScaler Networking
IP Address / vLAN / Routing Table / DNS
NetScaler Authentication
Local / LDAP
NetScaler Traffic Domain
Assigned Content Switch / Load Balancer / Service / Server
NetScaler Monitoring
NetScaler Certificate
NetScaler Content Switches
Assigned Load Balancer / Service / Server
NetScaler Load Balancer
Assigned Service / Server
NetScaler Service
Assigned Server / monitor
NetScaler Service Group
Assigned Server / monitor
NetScaler Server
NetScaler Custom Monitor
NetScaler Policy
NetScaler Action
NetScaler Profile
#>
Set-StrictMode -Version 2
#force -verbose on
$PSDefaultParameterValues = @{"*:Verbose"=$True}
$SaveEAPreference = $ErrorActionPreference
$ErrorActionPreference = 'SilentlyContinue'
If($PDF -eq $Null)
{
$PDF = $False
}
If($Text -eq $Null)
{
$Text = $False
}
If($MSWord -eq $Null)
{
$MSWord = $False
}
If($HTML -eq $Null)
{
$HTML = $False
}
If($AddDateTime -eq $Null)
{
$AddDateTime = $False
}
If($Hardware -eq $Null)
{
$Hardware = $False
}
If($ComputerName -eq $Null)
{
$ComputerName = "LocalHost"
}
If(!(Test-Path Variable:PDF))
{
$PDF = $False
}
If(!(Test-Path Variable:Text))
{
$Text = $False
}
If(!(Test-Path Variable:MSWord))
{
$MSWord = $False
}
If(!(Test-Path Variable:HTML))
{
$HTML = $False
}
If(!(Test-Path Variable:AddDateTime))
{
$AddDateTime = $False
}
If(!(Test-Path Variable:Hardware))
{
$Hardware = $False
}
If(!(Test-Path Variable:ComputerName))
{
$ComputerName = "LocalHost"
}
If($MSWord -eq $Null)
{
If($Text -or $HTML -or $PDF)
{
$MSWord = $False
}
Else
{
$MSWord = $True
}
}
If($MSWord -eq $False -and $PDF -eq $False -and $Text -eq $False -and $HTML -eq $False)
{
$MSWord = $True
}
Write-Verbose "$(Get-Date): Testing output parameters"
If($MSWord)
{
Write-Verbose "$(Get-Date): MSWord is set"
}
ElseIf($PDF)
{
Write-Verbose "$(Get-Date): PDF is set"
}
ElseIf($Text)
{
Write-Verbose "$(Get-Date): Text is set"
}
ElseIf($HTML)
{
Write-Verbose "$(Get-Date): HTML is set"
}
Else
{
$ErrorActionPreference = $SaveEAPreference
Write-Verbose "$(Get-Date): Unable to determine output parameter"
If($MSWord -eq $Null)
{
Write-Verbose "$(Get-Date): MSWord is Null"
}
ElseIf($PDF -eq $Null)
{
Write-Verbose "$(Get-Date): PDF is Null"
}
ElseIf($Text -eq $Null)
{
Write-Verbose "$(Get-Date): Text is Null"
}
ElseIf($HTML -eq $Null)
{
Write-Verbose "$(Get-Date): HTML is Null"
}
Else
{
Write-Verbose "$(Get-Date): MSWord is $($MSWord)"
Write-Verbose "$(Get-Date): PDF is $($PDF)"
Write-Verbose "$(Get-Date): Text is $($Text)"
Write-Verbose "$(Get-Date): HTML is $($HTML)"
}
Write-Error "Unable to determine output parameter. Script cannot continue"
Exit
}
If($MSWord -or $PDF)
{
#try and fix the issue with the $CompanyName variable
$CoName = $CompanyName
Write-Verbose "$(Get-Date): CoName is $($CoName)"
#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
[long]$wdColorGray15 = 14277081
[long]$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]$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
#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
[string]$RunningOS = (Get-WmiObject -class Win32_OperatingSystem -EA 0).Caption
}
Function GetComputerWMIInfo
{
Param([string]$RemoteComputerName)
# original work by Kees Baggerman,
# Senior Technical Consultant @ Inter Access
# @kbaggerman on Twitter
# http://blog.myvirtualvision.com
# modified 1-May-2014 to work in trusted AD Forests and using different domain admin credentials
#Get Computer info
Write-Verbose "$(Get-Date): `t`tProcessing WMI Computer information"
Write-Verbose "$(Get-Date): `t`t`tHardware information"
If($MSWord -or $PDF)
{
WriteWordLine 3 0 "Computer Information"
WriteWordLine 0 1 "General Computer"
}
ElseIf($Text)
{
Line 0 "Computer Information"
Line 1 "General Computer"
}
ElseIf($HTML)
{
}
[bool]$GotComputerItems = $True
Try
{
$Results = Get-WmiObject -computername $RemoteComputerName win32_computersystem
}
Catch
{
$Results = $Null
}
If($? -and $Results -ne $Null)
{
$ComputerItems = $Results | Select Manufacturer, Model, Domain, @{N="TotalPhysicalRam"; E={[math]::round(($_.TotalPhysicalMemory / 1GB),0)}}
$Results = $Null
ForEach($Item in $ComputerItems)
{
OutputComputerItem $Item
}
}
ElseIf(!$?)
{
Write-Verbose "$(Get-Date): 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
}
ElseIf($Text)
{
Line 2 "Get-WmiObject win32_computersystem failed for $($RemoteComputerName)"
Line 2 "On $($RemoteComputerName) you may need to run winmgmt /verifyrepository"
Line 2 "and winmgmt /salvagerepository. If this is a trusted Forest, you may"
Line 2 "need to rerun the script with Domain Admin credentials from the trusted Forest."
Line 2 ""
}
ElseIf($HTML)
{
}
}
Else
{
Write-Verbose "$(Get-Date): No results returned for Computer information"
If($MSWORD -or $PDF)
{
WriteWordLine 0 2 "No results returned for Computer information" "" $Null 0 $False $True
}
ElseIf($Text)
{
Line 2 "No results returned for Computer information"
}
ElseIf($HTML)
{
}
}
#Get Disk info
Write-Verbose "$(Get-Date): `t`t`tDrive information"
If($MSWord -or $PDF)
{
WriteWordLine 0 1 "Drive(s)"
}
ElseIf($Text)
{
Line 1 "Drive(s)"
}
ElseIf($HTML)
{
}
[bool]$GotDrives = $True
Try
{
$Results = Get-WmiObject -computername $RemoteComputerName Win32_LogicalDisk
}
Catch
{
$Results = $Null
}
If($? -and $Results -ne $Null)
{
$drives = $Results | Select caption, @{N="drivesize"; E={[math]::round(($_.size / 1GB),0)}},
filesystem, @{N="drivefreespace"; E={[math]::round(($_.freespace / 1GB),0)}},
volumename, drivetype, volumedirty, volumeserialnumber
$Results = $Null
ForEach($drive in $drives)
{
If($drive.caption -ne "A:" -and $drive.caption -ne "B:")
{
OutputDriveItem $drive
}
}
}
ElseIf(!$?)
{
Write-Verbose "$(Get-Date): Get-WmiObject Win32_LogicalDisk failed for $($RemoteComputerName)"
Write-Warning "Get-WmiObject Win32_LogicalDisk failed for $($RemoteComputerName)"
If($MSWORD -or $PDF)
{
WriteWordLine 0 2 "Get-WmiObject Win32_LogicalDisk 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
}
ElseIf($Text)
{
Line 2 "Get-WmiObject Win32_LogicalDisk failed for $($RemoteComputerName)"
Line 2 "On $($RemoteComputerName) you may need to run winmgmt /verifyrepository"
Line 2 "and winmgmt /salvagerepository. If this is a trusted Forest, you may"
Line 2 "need to rerun the script with Domain Admin credentials from the trusted Forest."
}
ElseIf($HTML)
{
}
}
Else
{
Write-Verbose "$(Get-Date): No results returned for Drive information"
If($MSWORD -or $PDF)
{
WriteWordLine 0 2 "No results returned for Drive information" "" $Null 0 $False $True
}
ElseIf($Text)
{
Line 2 "No results returned for Drive information"
}
ElseIf($HTML)
{
}
}
#Get CPU's and stepping
Write-Verbose "$(Get-Date): `t`t`tProcessor information"
If($MSWord -or $PDF)
{
WriteWordLine 0 1 "Processor(s)"
}
ElseIf($Text)
{
Line 1 "Processor(s)"
}
ElseIf($HTML)
{
}
[bool]$GotProcessors = $True
Try
{
$Results = Get-WmiObject -computername $RemoteComputerName win32_Processor
}
Catch
{
$Results = $Null
}
If($? -and $Results -ne $Null)
{
$Processors = $Results | Select availability, name, description, maxclockspeed,
l2cachesize, l3cachesize, numberofcores, numberoflogicalprocessors
$Results = $Null
ForEach($processor in $processors)
{
OutputProcessorItem $processor
}
}
ElseIf(!$?)
{
Write-Verbose "$(Get-Date): Get-WmiObject win32_Processor failed for $($RemoteComputerName)"
Write-Warning "Get-WmiObject win32_Processor failed for $($RemoteComputerName)"
If($MSWORD -or $PDF)
{
WriteWordLine 0 2 "Get-WmiObject win32_Processor 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
}
ElseIf($Text)
{
Line 2 "Get-WmiObject win32_Processor failed for $($RemoteComputerName)"
Line 2 "On $($RemoteComputerName) you may need to run winmgmt /verifyrepository"
Line 2 "and winmgmt /salvagerepository. If this is a trusted Forest, you may"
Line 2 "need to rerun the script with Domain Admin credentials from the trusted Forest."
}
ElseIf($HTML)
{
}
}
Else
{
Write-Verbose "$(Get-Date): No results returned for Processor information"
If($MSWORD -or $PDF)
{
WriteWordLine 0 2 "No results returned for Processor information" "" $Null 0 $False $True
}
ElseIf($Text)
{
Line 2 "No results returned for Processor information"
}
ElseIf($HTML)
{
}
}
#Get Nics
Write-Verbose "$(Get-Date): `t`t`tNIC information"
If($MSWord -or $PDF)
{
WriteWordLine 0 1 "Network Interface(s)"
}
ElseIf($Text)
{
Line 1 "Network Interface(s)"
}
ElseIf($HTML)
{
}
[bool]$GotNics = $True
Try
{
$Results = Get-WmiObject -computername $RemoteComputerName win32_networkadapterconfiguration
}
Catch
{
$Results
}
If($? -and $Results -ne $Null)
{
$Nics = $Results | Where {$_.ipaddress -ne $Null}
$Results = $Null
If($Nics -eq $Null )
{
$GotNics = $False
}
Else
{
$GotNics = !($Nics.__PROPERTY_COUNT -eq 0)
}
If($GotNics)
{
ForEach($nic in $nics)
{
Try
{
$ThisNic = Get-WmiObject -computername $RemoteComputerName win32_networkadapter | Where {$_.index -eq $nic.index}
}
Catch
{
$ThisNic = $Null
}
If($? -and $ThisNic -ne $Null)
{
OutputNicItem $Nic $ThisNic
}
ElseIf(!$?)
{
Write-Warning "$(Get-Date): Error retrieving NIC information"
Write-Verbose "$(Get-Date): Get-WmiObject win32_networkadapterconfiguration failed for $($RemoteComputerName)"
Write-Warning "Get-WmiObject win32_networkadapterconfiguration failed for $($RemoteComputerName)"
If($MSWORD -or $PDF)
{
WriteWordLine 0 2 "Error retrieving NIC information" "" $Null 0 $False $True
WriteWordLine 0 2 "Get-WmiObject win32_networkadapterconfiguration 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
}
ElseIf($Text)
{
Line 2 "Error retrieving NIC information"
Line 2 "Get-WmiObject win32_networkadapterconfiguration failed for $($RemoteComputerName)"
Line 2 "On $($RemoteComputerName) you may need to run winmgmt /verifyrepository"
Line 2 "and winmgmt /salvagerepository. If this is a trusted Forest, you may"
Line 2 "need to rerun the script with Domain Admin credentials from the trusted Forest."
}
ElseIf($HTML)
{
}
}
Else
{
Write-Verbose "$(Get-Date): No results returned for NIC information"
If($MSWORD -or $PDF)
{
WriteWordLine 0 2 "No results returned for NIC information" "" $Null 0 $False $True
}
ElseIf($Text)
{
Line 2 "No results returned for NIC information"
}
ElseIf($HTML)
{
}
}
}
}
}
ElseIf(!$?)
{
Write-Warning "$(Get-Date): Error retrieving NIC configuration information"
Write-Verbose "$(Get-Date): Get-WmiObject win32_networkadapterconfiguration failed for $($RemoteComputerName)"
Write-Warning "Get-WmiObject win32_networkadapterconfiguration failed for $($RemoteComputerName)"
If($MSWORD -or $PDF)
{
WriteWordLine 0 2 "Error retrieving NIC configuration information" "" $Null 0 $False $True
WriteWordLine 0 2 "Get-WmiObject win32_networkadapterconfiguration 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
}
ElseIf($Text)
{
Line 2 "Error retrieving NIC configuration information"
Line 2 "Get-WmiObject win32_networkadapterconfiguration failed for $($RemoteComputerName)"
Line 2 "On $($RemoteComputerName) you may need to run winmgmt /verifyrepository"
Line 2 "and winmgmt /salvagerepository. If this is a trusted Forest, you may"
Line 2 "need to rerun the script with Domain Admin credentials from the trusted Forest."
}
ElseIf($HTML)
{
}
}
Else
{
Write-Verbose "$(Get-Date): No results returned for NIC configuration information"
If($MSWORD -or $PDF)
{
WriteWordLine 0 2 "No results returned for NIC configuration information" "" $Null 0 $False $True
}
ElseIf($Text)
{
Line 2 "No results returned for NIC configuration information"
}
ElseIf($HTML)
{
}
}
If($MSWORD -or $PDF)
{
WriteWordLine 0 0 ""
}
ElseIf($Text)
{
Line 0 ""
}
ElseIf($HTML)
{
}
$Results = $Null
$ComputerItems = $Null
$Drives = $Null
$Processors = $Null
$Nics = $Null
}
Function OutputComputerItem
{
Param([object]$Item)
If($MSWord -or $PDF)
{
[System.Collections.Hashtable[]] $ItemInformation = @()
$ItemInformation += @{ Data = "Manufacturer"; Value = $Item.manufacturer; }
$ItemInformation += @{ Data = "Model"; Value = $Item.model; }
$ItemInformation += @{ Data = "Domain"; Value = $Item.domain; }
$ItemInformation += @{ Data = "Total Ram"; Value = "$($Item.totalphysicalram) GB"; }