-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPVS_Assessment.txt
3562 lines (3222 loc) · 117 KB
/
PVS_Assessment.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
<#
.SYNOPSIS
Creates a basic assessment of a Citrix PVS 5.x, 6.x or 7.x farm.
.DESCRIPTION
Creates a basic assessment of a Citrix PVS 5.x, 6.x or 7.x farm.
Creates a text document named after the PVS farm.
Register the PVS Console PowerShell Snap-in.
For versions of Windows prior to Windows 8 and Server 2012, run:
For 32-bit:
%systemroot%\Microsoft.NET\Framework\v2.0.50727\installutil.exe "%ProgramFiles%\Citrix\Provisioning Services Console\McliPSSnapIn.dll"
For 64-bit:
%systemroot%\Microsoft.NET\Framework64\v2.0.50727\installutil.exe "%ProgramFiles%\Citrix\Provisioning Services Console\McliPSSnapIn.dll"
For Windows 8.x, Server 2012 and Server 2012 R2, run:
For 32-bit:
%systemroot%\Microsoft.NET\Framework\v4.0.30319\installutil.exe "%ProgramFiles%\Citrix\Provisioning Services Console\McliPSSnapIn.dll"
For 64-bit:
%systemroot%\Microsoft.NET\Framework64\v4.0.30319\installutil.exe "%ProgramFiles%\Citrix\Provisioning Services Console\McliPSSnapIn.dll"
All lines are one line.
If you are running 64-bit Windows, you will need to run both commands so
the snap-in is registered for both 32-bit and 64-bit PowerShell.
.PARAMETER AdminAddress
Specifies the name of a PVS server that the PowerShell script will connect to.
Using this parameter requires the script be run from an elevated PowerShell session.
Starting with V1.11 of the script, this requirement is now checked.
This parameter has an alias of AA.
.PARAMETER User
Specifies the user used for the AdminAddress connection.
.PARAMETER Domain
Specifies the domain used for the AdminAddress connection.
.PARAMETER Password
Specifies the password used for the AdminAddress connection.
.PARAMETER Folder
Specifies the optional output folder to save the output report.
.PARAMETER SmtpServer
Specifies the optional email server to send the output report.
.PARAMETER SmtpPort
Specifies the SMTP port.
Default is 25.
.PARAMETER UseSSL
Specifies whether to use SSL for the SmtpServer.
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 > .\PVS_Assessment.ps1
Will use all Default values.
LocalHost for AdminAddress.
.EXAMPLE
PS C:\PSScript > .\PVS_Assessment.ps1 -AdminAddress PVS1 -User cwebster -Domain WebstersLab -Password Abc123!@#
This example is usually used to run the script against a PVS Farm in
another domain or forest.
Will use:
PVS1 for AdminAddress.
cwebster for User.
WebstersLab for Domain.
Abc123!@# for Password.
.EXAMPLE
PS C:\PSScript > .\PVS_Assessment.ps1 -AdminAddress PVS1 -User cwebster
Will use:
PVS1 for AdminAddress.
cwebster for User.
Script will prompt for the Domain and Password
.EXAMPLE
PS C:\PSScript > .\PVS_Assessment.ps1 -Folder \\FileServer\ShareName
Output file will be saved in the path \\FileServer\ShareName
.EXAMPLE
PS C:\PSScript > .\PVS_Assessment.ps1 -SmtpServer mail.domain.tld -From [email protected] -To [email protected] -ComputerName DHCPServer01
Script will use the email server mail.domain.tld, 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 > .\PVS_Assessment.ps1 -SmtpServer smtp.office365.com -SmtpPort 587 -UseSSL -From [email protected] -To [email protected]
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.
.INPUTS
None. You cannot pipe objects to this script.
.OUTPUTS
No objects are output from this script. This script creates a text file.
.NOTES
NAME: PVS_Assessment.ps1
VERSION: 1.11
AUTHOR: Carl Webster, Sr. Solutions Architect at Choice Solutions (with a lot of help from BG a, now former, Citrix dev)
LASTEDIT: September 12, 2016
#>
#thanks to @jeffwouters for helping me with these parameters
[CmdletBinding(SupportsShouldProcess = $False, ConfirmImpact = "None", DefaultParameterSetName = "Default") ]
Param(
[parameter(Mandatory=$False)]
[Alias("AA")]
[string]$AdminAddress="",
[parameter(ParameterSetName="Default",Mandatory=$False)]
[parameter(ParameterSetName="SMTP",Mandatory=$False)]
[string]$Domain=$env:UserDnsDomain,
[parameter(Mandatory=$False)]
[string]$User="",
[parameter(Mandatory=$False)]
[string]$Password="",
[parameter(Mandatory=$False)]
[string]$Folder="",
[parameter(ParameterSetName="SMTP",Mandatory=$True)]
[string]$SmtpServer="",
[parameter(ParameterSetName="SMTP",Mandatory=$False)]
[int]$SmtpPort=25,
[parameter(ParameterSetName="SMTP",Mandatory=$False)]
[switch]$UseSSL=$False,
[parameter(ParameterSetName="SMTP",Mandatory=$True)]
[string]$From="",
[parameter(ParameterSetName="SMTP",Mandatory=$True)]
[string]$To=""
)
#Carl Webster, CTP and Sr. Solutions Architect at Choice Solutions
#@carlwebster on Twitter
#http://www.CarlWebster.com
#script created August 8, 2015
#released to the community on February 2, 2016
#
#Version 1.11
# Added an alias AA for AdminAddress to match the other scripts that use AdminAddress
# Added output to appendixes to show if nothing was found
# Added checking for $ComputerName parameter when testing PVS services
# Changed the "No unassociated vDisks found" to "<None found>" to match the changes to the other Appendixes
# Fixed an issue where Appendix I was not output
# Fixed error message in output when no PVS services were found (said No Bootstraps found)
# If remoting is used (-AdminAddress), check if the script is being run elevated. If not,
# show the script needs elevation and end the script
# Removed all references to $ErrorActionPreference since it is no longer used
#
#Version 1.10 8-Sep-2016
# Added Appendix K for 33 Misc Registry Keys
# Miscellaneous Registry Items That May or May Not Exist on Servers
# These items may or may not be needed
# This Appendix is strictly for server comparison only
# Added Break statements to most of the Switch statements
# Added checking the NIC's "Allow the computer to turn off this device to save power" setting
# Added function Get-RegKeyToObject contributed by Andrew Williamson @ Fujitsu Services
# Added testing for $Null –eq $DiskLocators. PoSH V2 did not like that I forgot to do that
# Added to the console and report, lines when nothing was found for various items being checked
# Cleaned up duplicate IP addresses appearing in Appendix J
# Changed NICIPAddressess from array to hashtable
# Reset the StreamingIPAddresses array between servers
# Moved the initialization of arrays to the top of the script instead of inside a function
# PoSH V2 did not like the “4>$Null”. I test for V2 now and use “2>$Null”
# Script now works properly with PoSH V2 and PVS 5.x.x
# Since PoSH V2 does not work with the way I forced Verbose on, I changed all the Write-Verbose statements to Write-Host
# You should not be able to tell any difference
# With the help and patience of Andrew Williamson and MBS, the script should now work with PVS servers that have multiple NICs
#
#Version 1.04 1-Aug-2016
# Added back missing AdminAddress, User and Password parameters
# Fixed several invalid output lines
#
#Version 1.03 22-Feb-2016
# Added validating the Store Path and Write Cache locations
#
#Version 1.02 17-Feb-2016
# In help text, changed the DLL registration lines to not wrap
# In help text, changed the smart quotes to regular quotes
# Added for Appendix E a link to the Citrix article on DisableTaskOffload
# Added link to PVS server sizing for server RAM calculation
# Added comparing Streaming IP addresses to the IP addresses configured for the server
# If a streaming IP address does not exist on the server, it is an invalid streaming IP address
# This is a bug in PVS that allows invalid IP addresses to be added for streaming IPs
#
#Version 1.01 8-Feb-2016
# Added specifying an optional output folder
# Added the option to email the output file
# Fixed several spacing and typo errors
Set-StrictMode -Version 2
If(!(Test-Path Variable:AdminAddress))
{
$AdminAddress = ""
}
If(!(Test-Path Variable:User))
{
$User = ""
}
If(!(Test-Path Variable:Domain))
{
$Domain = ""
}
If(!(Test-Path Variable:Password))
{
$Password = ""
}
If(!(Test-Path Variable:Folder))
{
$Folder = ""
}
If(!(Test-Path Variable:SmtpServer))
{
$SmtpServer = ""
}
If(!(Test-Path Variable:SmtpPort))
{
$SmtpPort = 25
}
If(!(Test-Path Variable:UseSSL))
{
$UseSSL = $False
}
If(!(Test-Path Variable:From))
{
$From = ""
}
If(!(Test-Path Variable:To))
{
$To = ""
}
If($Null -eq $AdminAddress)
{
$AdminAddress = ""
}
If($Null -eq $User)
{
$User = ""
}
If($Null -eq $Domain)
{
$Domain = ""
}
If($Null -eq $Password)
{
$Password = ""
}
If($Null -eq $Folder)
{
$Folder = ""
}
If($Null -eq $SmtpServer)
{
$SmtpServer = ""
}
If($Null -eq $SmtpPort)
{
$SmtpPort = 25
}
If($Null -eq $UseSSL)
{
$UseSSL = $False
}
If($Null -eq $From)
{
$From = ""
}
If($Null -eq $To)
{
$To = ""
}
If($Folder -ne "")
{
Write-Host -foregroundcolor Yellow -backgroundcolor Black "VERBOSE: $(Get-Date): 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-Host -foregroundcolor Yellow -backgroundcolor Black "VERBOSE: $(Get-Date): Folder path $Folder exists and is a folder"
}
Else
{
#it exists but it is a file not a folder
Write-Error "Folder $Folder is a file, not a folder. Script cannot continue"
Exit
}
}
Else
{
#does not exist
Write-Error "Folder $Folder does not exist. Script cannot continue"
Exit
}
}
$Script:AdvancedItems1 = @()
$Script:AdvancedItems2 = @()
$Script:ConfigWizItems = @()
$Script:BootstrapItems = @()
$Script:TaskOffloadItems = @()
$Script:PVSServiceItems = @()
$Script:VersionsToMerge = @()
$Script:NICIPAddresses = @{}
$Script:StreamingIPAddresses = @()
$Script:BadIPs = @()
$Script:EmptyDeviceCollections = @()
$Script:MiscRegistryItems = @()
#region code for -hardware switch
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-Host -foregroundcolor Yellow -backgroundcolor Black "VERBOSE: $(Get-Date): Processing WMI Computer information"
Write-Host -foregroundcolor Yellow -backgroundcolor Black "VERBOSE: $(Get-Date): Hardware information"
Line 2 "General Computer"
[bool]$GotComputerItems = $True
Try
{
$Results = Get-WmiObject -computername $RemoteComputerName win32_computersystem
}
Catch
{
$Results = $Null
}
If($? -and $Null -ne $Results)
{
$ComputerItems = $Results | Select Manufacturer, Model, Domain, `
@{N="TotalPhysicalRam"; E={[math]::round(($_.TotalPhysicalMemory / 1GB),0)}}, `
NumberOfProcessors, NumberOfLogicalProcessors
$Results = $Null
ForEach($Item in $ComputerItems)
{
OutputComputerItem $Item
}
}
ElseIf(!$?)
{
Write-Host -foregroundcolor Yellow -backgroundcolor Black "VERBOSE: $(Get-Date): Get-WmiObject win32_computersystem failed for $($RemoteComputerName)"
Write-Warning "Get-WmiObject win32_computersystem failed for $($RemoteComputerName)"
Line 3 "Get-WmiObject win32_computersystem failed for $($RemoteComputerName)"
Line 3 "On $($RemoteComputerName) you may need to run winmgmt /verifyrepository"
Line 3 "and winmgmt /salvagerepository. If this is a trusted Forest, you may"
Line 3 "need to rerun the script with Domain Admin credentials from the trusted Forest."
Line 3 ""
}
Else
{
Write-Host -foregroundcolor Yellow -backgroundcolor Black "VERBOSE: $(Get-Date): No results Returned for Computer information"
Line 3 "No results Returned for Computer information"
}
#Get Disk info
Write-Host -foregroundcolor Yellow -backgroundcolor Black "VERBOSE: $(Get-Date): Drive information"
Line 2 "Drive(s)"
[bool]$GotDrives = $True
Try
{
$Results = Get-WmiObject -computername $RemoteComputerName Win32_LogicalDisk
}
Catch
{
$Results = $Null
}
If($? -and $Null -ne $Results)
{
$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:" -and $drive.drivetype -ne 5)
{
OutputDriveItem $drive
}
}
}
ElseIf(!$?)
{
Write-Host -foregroundcolor Yellow -backgroundcolor Black "VERBOSE: $(Get-Date): Get-WmiObject Win32_LogicalDisk failed for $($RemoteComputerName)"
Write-Warning "Get-WmiObject Win32_LogicalDisk failed for $($RemoteComputerName)"
Line 3 "Get-WmiObject Win32_LogicalDisk failed for $($RemoteComputerName)"
Line 3 "On $($RemoteComputerName) you may need to run winmgmt /verifyrepository"
Line 3 "and winmgmt /salvagerepository. If this is a trusted Forest, you may"
Line 3 "need to rerun the script with Domain Admin credentials from the trusted Forest."
}
Else
{
Write-Host -foregroundcolor Yellow -backgroundcolor Black "VERBOSE: $(Get-Date): No results Returned for Drive information"
Line 3 "No results Returned for Drive information"
}
#Get CPU's and stepping
Write-Host -foregroundcolor Yellow -backgroundcolor Black "VERBOSE: $(Get-Date): Processor information"
Line 2 "Processor(s)"
[bool]$GotProcessors = $True
Try
{
$Results = Get-WmiObject -computername $RemoteComputerName win32_Processor
}
Catch
{
$Results = $Null
}
If($? -and $Null -ne $Results)
{
$Processors = $Results | Select availability, name, description, maxclockspeed,
l2cachesize, l3cachesize, numberofcores, numberoflogicalprocessors
$Results = $Null
ForEach($processor in $processors)
{
OutputProcessorItem $processor
}
}
ElseIf(!$?)
{
Write-Host -foregroundcolor Yellow -backgroundcolor Black "VERBOSE: $(Get-Date): Get-WmiObject win32_Processor failed for $($RemoteComputerName)"
Write-Warning "Get-WmiObject win32_Processor failed for $($RemoteComputerName)"
Line 3 "Get-WmiObject win32_Processor failed for $($RemoteComputerName)"
Line 3 "On $($RemoteComputerName) you may need to run winmgmt /verifyrepository"
Line 3 "and winmgmt /salvagerepository. If this is a trusted Forest, you may"
Line 3 "need to rerun the script with Domain Admin credentials from the trusted Forest."
}
Else
{
Write-Host -foregroundcolor Yellow -backgroundcolor Black "VERBOSE: $(Get-Date): No results Returned for Processor information"
Line 3 "No results Returned for Processor information"
}
#Get Nics
Write-Host -foregroundcolor Yellow -backgroundcolor Black "VERBOSE: $(Get-Date): NIC information"
Line 2 "Network Interface(s)"
[bool]$GotNics = $True
Try
{
$Results = Get-WmiObject -computername $RemoteComputerName win32_networkadapterconfiguration
}
Catch
{
$Results
}
If($? -and $Null -ne $Results)
{
$Nics = $Results | Where {$Null -ne $_.ipaddress}
$Results = $Null
If($Null -eq $Nics)
{
$GotNics = $False
}
Else
{
If($Nics -is [array])
{
$GotNics = !($Nics[0].__PROPERTY_COUNT -eq 0)
}
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 $Null -ne $ThisNic)
{
OutputNicItem $Nic $ThisNic $RemoteComputerName
}
ElseIf(!$?)
{
Write-Warning "$(Get-Date): Error retrieving NIC information"
Write-Host -foregroundcolor Yellow -backgroundcolor Black "VERBOSE: $(Get-Date): Get-WmiObject win32_networkadapterconfiguration failed for $($RemoteComputerName)"
Write-Warning "Get-WmiObject win32_networkadapterconfiguration failed for $($RemoteComputerName)"
Line 3 "Error retrieving NIC information"
Line 3 "Get-WmiObject win32_networkadapterconfiguration failed for $($RemoteComputerName)"
Line 3 "On $($RemoteComputerName) you may need to run winmgmt /verifyrepository"
Line 3 "and winmgmt /salvagerepository. If this is a trusted Forest, you may"
Line 3 "need to rerun the script with Domain Admin credentials from the trusted Forest."
}
Else
{
Write-Host -foregroundcolor Yellow -backgroundcolor Black "VERBOSE: $(Get-Date): No results Returned for NIC information"
Line 3 "No results Returned for NIC information"
}
}
}
}
ElseIf(!$?)
{
Write-Warning "$(Get-Date): Error retrieving NIC configuration information"
Write-Host -foregroundcolor Yellow -backgroundcolor Black "VERBOSE: $(Get-Date): Get-WmiObject win32_networkadapterconfiguration failed for $($RemoteComputerName)"
Write-Warning "Get-WmiObject win32_networkadapterconfiguration failed for $($RemoteComputerName)"
Line 3 "Error retrieving NIC configuration information"
Line 3 "Get-WmiObject win32_networkadapterconfiguration failed for $($RemoteComputerName)"
Line 3 "On $($RemoteComputerName) you may need to run winmgmt /verifyrepository"
Line 3 "and winmgmt /salvagerepository. If this is a trusted Forest, you may"
Line 3 "need to rerun the script with Domain Admin credentials from the trusted Forest."
}
Else
{
Write-Host -foregroundcolor Yellow -backgroundcolor Black "VERBOSE: $(Get-Date): No results Returned for NIC configuration information"
Line 3 "No results Returned for NIC configuration information"
}
Line 1 ""
$Results = $Null
$ComputerItems = $Null
$Drives = $Null
$Processors = $Null
$Nics = $Null
}
Function OutputComputerItem
{
Param([object]$Item)
Line 3 "Manufacturer: " $Item.manufacturer
Line 3 "Model: " $Item.model
Line 3 "Domain: " $Item.domain
Line 3 "Total Ram: $($Item.totalphysicalram) GB"
Line 3 "Physical Processors (sockets): " $Item.NumberOfProcessors
Line 3 "Logical Processors (cores w/HT): " $Item.NumberOfLogicalProcessors
Line 3 ""
}
Function OutputDriveItem
{
Param([object]$Drive)
$xDriveType = ""
Switch ($drive.drivetype)
{
0 {$xDriveType = "Unknown"; Break}
1 {$xDriveType = "No Root Directory"; Break}
2 {$xDriveType = "Removable Disk"; Break}
3 {$xDriveType = "Local Disk"; Break}
4 {$xDriveType = "Network Drive"; Break}
5 {$xDriveType = "Compact Disc"; Break}
6 {$xDriveType = "RAM Disk"; Break}
Default {$xDriveType = "Unknown"; Break}
}
$xVolumeDirty = ""
If(![String]::IsNullOrEmpty($drive.volumedirty))
{
If($drive.volumedirty)
{
$xVolumeDirty = "Yes"
}
Else
{
$xVolumeDirty = "No"
}
}
Line 3 "Caption: " $drive.caption
Line 3 "Size: $($drive.drivesize) GB"
If(![String]::IsNullOrEmpty($drive.filesystem))
{
Line 3 "File System: " $drive.filesystem
}
Line 3 "Free Space: $($drive.drivefreespace) GB"
If(![String]::IsNullOrEmpty($drive.volumename))
{
Line 3 "Volume Name: " $drive.volumename
}
If(![String]::IsNullOrEmpty($drive.volumedirty))
{
Line 3 "Volume is Dirty: " $xVolumeDirty
}
If(![String]::IsNullOrEmpty($drive.volumeserialnumber))
{
Line 3 "Volume Serial #: " $drive.volumeserialnumber
}
Line 3 "Drive Type: " $xDriveType
Line 3 ""
}
Function OutputProcessorItem
{
Param([object]$Processor)
$xAvailability = ""
Switch ($processor.availability)
{
1 {$xAvailability = "Other"; Break }
2 {$xAvailability = "Unknown"; Break }
3 {$xAvailability = "Running or Full Power"; Break }
4 {$xAvailability = "Warning"; Break }
5 {$xAvailability = "In Test"; Break }
6 {$xAvailability = "Not Applicable"; Break }
7 {$xAvailability = "Power Off"; Break }
8 {$xAvailability = "Off Line"; Break }
9 {$xAvailability = "Off Duty"; Break }
10 {$xAvailability = "Degraded"; Break }
11 {$xAvailability = "Not Installed"; Break }
12 {$xAvailability = "Install Error"; Break }
13 {$xAvailability = "Power Save - Unknown"; Break }
14 {$xAvailability = "Power Save - Low Power Mode"; Break }
15 {$xAvailability = "Power Save - Standby"; Break }
16 {$xAvailability = "Power Cycle"; Break }
17 {$xAvailability = "Power Save - Warning"; Break }
Default {$xAvailability = "Unknown"; Break }
}
Line 3 "Name: " $processor.name
Line 3 "Description: " $processor.description
Line 3 "Max Clock Speed: $($processor.maxclockspeed) MHz"
If($processor.l2cachesize -gt 0)
{
Line 3 "L2 Cache Size: $($processor.l2cachesize) KB"
}
If($processor.l3cachesize -gt 0)
{
Line 3 "L3 Cache Size: $($processor.l3cachesize) KB"
}
If($processor.numberofcores -gt 0)
{
Line 3 "# of Cores: " $processor.numberofcores
}
If($processor.numberoflogicalprocessors -gt 0)
{
Line 3 "# of Logical Procs (cores w/HT): " $processor.numberoflogicalprocessors
}
Line 3 "Availability: " $xAvailability
Line 3 ""
}
Function OutputNicItem
{
Param([object]$Nic, [object]$ThisNic, [string] $ComputerName)
$powerMgmt = Get-WmiObject MSPower_DeviceEnable -Namespace root\wmi | where {$_.InstanceName -match [regex]::Escape($ThisNic.PNPDeviceID)}
If($? -and $Null -ne $powerMgmt)
{
If($powerMgmt.Enable -eq $True)
{
$PowerSaving = "Enabled"
}
Else
{
$PowerSaving = "Disabled"
}
}
Else
{
$PowerSaving = "N/A"
}
$xAvailability = ""
Switch ($processor.availability)
{
1 {$xAvailability = "Other"; Break }
2 {$xAvailability = "Unknown"; Break }
3 {$xAvailability = "Running or Full Power"; Break }
4 {$xAvailability = "Warning"; Break }
5 {$xAvailability = "In Test"; Break }
6 {$xAvailability = "Not Applicable"; Break }
7 {$xAvailability = "Power Off"; Break }
8 {$xAvailability = "Off Line"; Break }
9 {$xAvailability = "Off Duty"; Break }
10 {$xAvailability = "Degraded"; Break }
11 {$xAvailability = "Not Installed"; Break }
12 {$xAvailability = "Install Error"; Break }
13 {$xAvailability = "Power Save - Unknown"; Break }
14 {$xAvailability = "Power Save - Low Power Mode"; Break }
15 {$xAvailability = "Power Save - Standby"; Break }
16 {$xAvailability = "Power Cycle"; Break }
17 {$xAvailability = "Power Save - Warning"; Break }
Default {$xAvailability = "Unknown"; Break }
}
$xIPAddresses = @()
ForEach($IPAddress in $Nic.ipaddress)
{
$xIPAddresses += "$($IPAddress)"
#$Script:NICIPAddresses.Add($ComputerName, $IPAddress)
If($Script:NICIPAddresses.ContainsKey($ComputerName))
{
$MultiIP = @()
$MultiIP += $Script:NICIPAddresses.Item($ComputerName)
$MultiIP += $IPAddress
$Script:NICIPAddresses.Item($ComputerName) = $MultiIP
}
Else
{
$Script:NICIPAddresses.Add($ComputerName,$IPAddress)
}
}
$xIPSubnet = @()
ForEach($IPSubnet in $Nic.ipsubnet)
{
$xIPSubnet += "$($IPSubnet)"
}
If($Null -ne $nic.dnsdomainsuffixsearchorder -and $nic.dnsdomainsuffixsearchorder.length -gt 0)
{
$nicdnsdomainsuffixsearchorder = $nic.dnsdomainsuffixsearchorder
$xnicdnsdomainsuffixsearchorder = @()
ForEach($DNSDomain in $nicdnsdomainsuffixsearchorder)
{
$xnicdnsdomainsuffixsearchorder += "$($DNSDomain)"
}
}
If($Null -ne $nic.dnsserversearchorder -and $nic.dnsserversearchorder.length -gt 0)
{
$nicdnsserversearchorder = $nic.dnsserversearchorder
$xnicdnsserversearchorder = @()
ForEach($DNSServer in $nicdnsserversearchorder)
{
$xnicdnsserversearchorder += "$($DNSServer)"
}
}
$xdnsenabledforwinsresolution = ""
If($nic.dnsenabledforwinsresolution)
{
$xdnsenabledforwinsresolution = "Yes"
}
Else
{
$xdnsenabledforwinsresolution = "No"
}
$xTcpipNetbiosOptions = ""
Switch ($nic.TcpipNetbiosOptions)
{
0 {$xTcpipNetbiosOptions = "Use NetBIOS setting from DHCP Server"; Break}
1 {$xTcpipNetbiosOptions = "Enable NetBIOS"; Break}
2 {$xTcpipNetbiosOptions = "Disable NetBIOS"; Break}
Default {$xTcpipNetbiosOptions = "Unknown"; Break}
}
$xwinsenablelmhostslookup = ""
If($nic.winsenablelmhostslookup)
{
$xwinsenablelmhostslookup = "Yes"
}
Else
{
$xwinsenablelmhostslookup = "No"
}
Line 3 "Name: " $ThisNic.Name
If($ThisNic.Name -ne $nic.description)
{
Line 3 "Description: " $nic.description
}
Line 3 "Connection ID: " $ThisNic.NetConnectionID
Line 3 "Manufacturer: " $ThisNic.manufacturer
Line 3 "Availability: " $xAvailability
Line 3 "Allow the computer to turn off this device to save power: " $PowerSaving
Line 3 "Physical Address: " $nic.macaddress
Line 3 "IP Address: " $xIPAddresses[0]
$cnt = -1
ForEach($tmp in $xIPAddresses)
{
$cnt++
If($cnt -gt 0)
{
Line 4 " " $tmp
}
}
Line 3 "Default Gateway: " $Nic.Defaultipgateway
Line 3 "Subnet Mask: " $xIPSubnet[0]
$cnt = -1
ForEach($tmp in $xIPSubnet)
{
$cnt++
If($cnt -gt 0)
{
Line 4 " " $tmp
}
}
If($nic.dhcpenabled)
{
$DHCPLeaseObtainedDate = $nic.ConvertToDateTime($nic.dhcpleaseobtained)
$DHCPLeaseExpiresDate = $nic.ConvertToDateTime($nic.dhcpleaseexpires)
Line 3 "DHCP Enabled: " $nic.dhcpenabled
Line 3 "DHCP Lease Obtained: " $dhcpleaseobtaineddate
Line 3 "DHCP Lease Expires: " $dhcpleaseexpiresdate
Line 3 "DHCP Server:" $nic.dhcpserver
}
If(![String]::IsNullOrEmpty($nic.dnsdomain))
{
Line 3 "DNS Domain: " $nic.dnsdomain
}
If($Null -ne $nic.dnsdomainsuffixsearchorder -and $nic.dnsdomainsuffixsearchorder.length -gt 0)
{
[int]$x = 1
Line 3 "DNS Search Suffixes: " $xnicdnsdomainsuffixsearchorder[0]
$cnt = -1
ForEach($tmp in $xnicdnsdomainsuffixsearchorder)
{
$cnt++
If($cnt -gt 0)
{
Line 4 " " $tmp
}
}
}
Line 3 "DNS WINS Enabled: " $xdnsenabledforwinsresolution
If($Null -ne $nic.dnsserversearchorder -and $nic.dnsserversearchorder.length -gt 0)
{
[int]$x = 1
Line 3 "DNS Servers: " $xnicdnsserversearchorder[0]
$cnt = -1
ForEach($tmp in $xnicdnsserversearchorder)
{
$cnt++
If($cnt -gt 0)
{
Line 4 " " $tmp
}
}
}
Line 3 "NetBIOS Setting: " $xTcpipNetbiosOptions
Line 3 "Enabled LMHosts: " $xwinsenablelmhostslookup
If(![String]::IsNullOrEmpty($nic.winshostlookupfile))
{
Line 3 "Host Lookup File: " $nic.winshostlookupfile
}
If(![String]::IsNullOrEmpty($nic.winsprimaryserver))
{
Line 3 "Primary Server: " $nic.winsprimaryserver
}
If(![String]::IsNullOrEmpty($nic.winssecondaryserver))
{
Line 3 "Secondary Server: " $nic.winssecondaryserver
}
If(![String]::IsNullOrEmpty($nic.winsscopeid))
{
Line 3 "Scope ID: " $nic.winsscopeid
}
Line 0 ""
}
#endregion
#region email function
Function SendEmail
{
Param([string]$Attachments)
Write-Host -foregroundcolor Yellow -backgroundcolor Black "VERBOSE: $(Get-Date): Prepare to email"
$emailAttachment = $Attachments
$emailSubject = $Script:Title
$emailBody = @"
Hello, <br />
<br />
$Script:Title is attached.
"@
$error.Clear()
If($UseSSL)
{
Write-Host -foregroundcolor Yellow -backgroundcolor Black "VERBOSE: $(Get-Date): Trying to send email using current user's credentials with SSL"
Send-MailMessage -Attachments $emailAttachment -Body $emailBody -BodyAsHtml -From $From `
-Port $SmtpPort -SmtpServer $SmtpServer -Subject $emailSubject -To $To `
-UseSSL *>$Null
}
Else
{
Write-Verbose "$(Get-Date): Trying to send email using current user's credentials without SSL"
Send-MailMessage -Attachments $emailAttachment -Body $emailBody -BodyAsHtml -From $From `
-Port $SmtpPort -SmtpServer $SmtpServer -Subject $emailSubject -To $To *>$Null
}
$e = $error[0]
If($e.Exception.ToString().Contains("5.7.57"))
{
#The server response was: 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM
Write-Host -foregroundcolor Yellow -backgroundcolor Black "VERBOSE: $(Get-Date): Current user's credentials failed. Ask for usable credentials."
$emailCredentials = Get-Credential -Message "Enter the email account and password to send email"
$error.Clear()
If($UseSSL)
{
Send-MailMessage -Attachments $emailAttachment -Body $emailBody -BodyAsHtml -From $From `
-Port $SmtpPort -SmtpServer $SmtpServer -Subject $emailSubject -To $To `
-UseSSL -credential $emailCredentials *>$Null
}
Else
{
Send-MailMessage -Attachments $emailAttachment -Body $emailBody -BodyAsHtml -From $From `
-Port $SmtpPort -SmtpServer $SmtpServer -Subject $emailSubject -To $To `
-credential $emailCredentials *>$Null
}
$e = $error[0]
If($? -and $Null -eq $e)
{
Write-Host -foregroundcolor Yellow -backgroundcolor Black "VERBOSE: $(Get-Date): Email successfully sent using new credentials"
}
Else
{
Write-Host -foregroundcolor Yellow -backgroundcolor Black "VERBOSE: $(Get-Date): Email was not sent:"
Write-Warning "$(Get-Date): Exception: $e.Exception"
}
}
Else
{
Write-Host -foregroundcolor Yellow -backgroundcolor Black "VERBOSE: $(Get-Date): Email was not sent:"
Write-Warning "$(Get-Date): Exception: $e.Exception"
}
}
#endregion
Function GetConfigWizardInfo
{
Param([string]$ComputerName)
$DHCPServicesValue = Get-RegistryValue "HKLM:\SOFTWARE\Citrix\ProvisioningServices\Wizard" "DHCPType" $ComputerName
$PXEServiceValue = Get-RegistryValue "HKLM:\SOFTWARE\Citrix\ProvisioningServices\Wizard" "PXEType" $ComputerName
$DHCPServices = ""
$PXEService = ""
Switch ($DHCPServicesValue)
{
1073741824 {$DHCPServices = "The service that runs on another computer"; Break}
0 {$DHCPServices = "Microsoft DHCP"; Break}
1 {$DHCPServices = "Provisioning Services BOOTP service"; Break}
2 {$DHCPServices = "Other BOOTP or DHCP service"; Break}
Default {$DHCPServices = "Unable to determine DHCPServices: $($DHCPServiceValue)"; Break}
}
If($DHCPServicesValue -eq 1073741824)
{
Switch ($PXEServiceValue)
{
1073741824 {$PXEServices = "The service that runs on another computer"; Break}
0 {$PXEServices = "Provisioning Services PXE service"; Break}
Default {$PXEServices = "Unable to determine PXEServices: $($PXEServiceValue)"; Break}
}
}