-
Notifications
You must be signed in to change notification settings - Fork 61
/
Start-PoshPAIG.ps1
2315 lines (2140 loc) · 225 KB
/
Start-PoshPAIG.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#region Synchronized Collections
$uiHash = [hashtable]::Synchronized(@{})
$runspaceHash = [hashtable]::Synchronized(@{})
$jobs = [system.collections.arraylist]::Synchronized((New-Object System.Collections.ArrayList))
$jobCleanup = [hashtable]::Synchronized(@{})
$Global:updateAudit = [system.collections.arraylist]::Synchronized((New-Object System.Collections.ArrayList))
$Global:installAudit = [system.collections.arraylist]::Synchronized((New-Object System.Collections.ArrayList))
$Global:servicesAudit = [system.collections.arraylist]::Synchronized((New-Object System.Collections.ArrayList))
$Global:installedUpdates = [system.collections.arraylist]::Synchronized((New-Object System.Collections.ArrayList))
#endregion
#region Startup Checks and configurations
#Determine if running from ISE
Write-Verbose "Checking to see if running from console"
If ($Host.name -eq "Windows PowerShell ISE Host") {
Write-Warning "Unable to run this from the PowerShell ISE due to issues with PSexec!`nPlease run from console."
Break
}
#Validate user is an Administrator
Write-Verbose "Checking Administrator credentials"
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
[Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Warning "You are not running this as an Administrator!`nRe-running script and will prompt for administrator credentials."
Start-Process -Verb "Runas" -File PowerShell.exe -Argument "-STA -noprofile -file $($myinvocation.mycommand.definition)"
Break
}
#Ensure that we are running the GUI from the correct location
Set-Location $(Split-Path $MyInvocation.MyCommand.Path)
$Global:Path = $(Split-Path $MyInvocation.MyCommand.Path)
Write-Debug "Current location: $Path"
#Check for PSExec
Write-Verbose "Checking for psexec.exe"
If (-Not (Test-Path psexec.exe)) {
Write-Warning ("Psexec.exe missing from {0}!`n Please place file in the path so UI can work properly" -f (Split-Path $MyInvocation.MyCommand.Path))
Break
}
#Determine if this instance of PowerShell can run WPF
Write-Verbose "Checking the apartment state"
If ($host.Runspace.ApartmentState -ne "STA") {
Write-Warning "This script must be run in PowerShell started using -STA switch!`nScript will attempt to open PowerShell in STA and run re-run script."
Start-Process -File PowerShell.exe -Argument "-STA -noprofile -WindowStyle hidden -file $($myinvocation.mycommand.definition)"
Break
}
#Load Required Assemblies
Add-Type –assemblyName PresentationFramework
Add-Type –assemblyName PresentationCore
Add-Type –assemblyName WindowsBase
Add-Type –assemblyName Microsoft.VisualBasic
Add-Type –assemblyName System.Windows.Forms
#Computer Cache collection
$Script:ComputerCache = New-Object System.Collections.ArrayList
#DotSource Help script
. ".\HelpFiles\HelpOverview.ps1"
#DotSource About script
. ".\HelpFiles\About.ps1"
#endregion
Function Set-PoshPAIGOption {
[CmdletBinding()]
Param ()
# Craig Tolley - 05 August 2016
# - Updated to use Environment to get Desktop location
# - Check for valid report path on load
# - Export-CliXML updated to use $Path instead of $pwd
# - Simplified the setting/testing of options, either load/set defaults and then run validation
# If the Options.xml file exists, then use it, if not then set default option values
# Also, if the imported options are Null, then rebuild
$Optionshash = $Null
If (Test-Path (Join-Path $Path 'options.xml')) {
Write-Debug "Options.xml file found"
$Optionshash = Import-Clixml -Path (Join-Path $Path 'options.xml')
}
If ($Optionshash -eq $null) {
Write-Debug "Options.xml file not present. Setting default values"
$optionshash = @{
MaxJobs = 5
MaxRebootJobs = 5
ReportPath = [Environment]::GetFolderPath("Desktop")
}
}
# Validate the MaxJobs Option
If ($Optionshash['MaxJobs'])
{
If ([int]$Optionshash['MaxJobs'] -gt 1) {
$Global:maxConcurrentJobs = $Optionshash['MaxJobs']
} Else {
$Optionshash['MaxJobs'] = $Global:maxConcurrentJobs = 5
}
} Else {
$Optionshash['MaxJobs'] = $Global:maxConcurrentJobs = 5
}
# Validate the MaxRebootJobs Option
If ($Optionshash['MaxRebootJobs'])
{
If ([int]$Optionshash['MaxRebootJobs'] -gt 1) {
$Global:maxRebootJobs = $Optionshash['MaxRebootJobs']
} Else {
$Optionshash['MaxRebootJobs'] = $Global:maxRebootJobs = 5
}
} Else {
$Optionshash['MaxRebootJobs'] = $Global:maxRebootJobs = 5
}
# Validate the ReportPath Option
If ($Optionshash['ReportPath']) {
If (Test-Path $Optionshash['ReportPath']) {
Write-Debug "Stored ReportPath option found and is valid"
$Global:reportpath = $Optionshash['ReportPath']
} Else {
Write-Debug "Stored ReportPath option is invalid. Reverting to default"
$Optionshash['ReportPath'] = $Global:reportpath = [Environment]::GetFolderPath("Desktop")
}
} Else {
Write-Debug "ReportPath option not found in imported file. Reverting to default"
$Optionshash['ReportPath'] = $Global:reportpath = [Environment]::GetFolderPath("Desktop")
}
# Export all options, regardless of whether they are the same as what is already in the file
Write-Debug "Exporting options.xml"
$optionshash | Export-Clixml -Path (Join-Path $Path 'options.xml') -Force
}
#Function for Debug output
Function Global:Show-DebugState {
Write-Debug ("Number of Items: {0}" -f $uiHash.Listview.ItemsSource.count)
Write-Debug ("First Item: {0}" -f $uiHash.Listview.ItemsSource[0].Computer)
Write-Debug ("Last Item: {0}" -f $uiHash.Listview.ItemsSource[$($uiHash.Listview.ItemsSource.count) -1].Computer)
Write-Debug ("Max Progress Bar: {0}" -f $uiHash.ProgressBar.Maximum)
}
#Reboot Warning Message
Function Show-RebootWarning {
$title = "Reboot Server Warning"
$message = "You are about to reboot servers which can affect the environment! `nAre you sure you want to do this?"
$button = [System.Windows.Forms.MessageBoxButtons]::YesNo
$icon = [Windows.Forms.MessageBoxIcon]::Warning
[windows.forms.messagebox]::Show($message,$title,$button,$icon)
}
#Format and display errors
Function Get-Error {
Process {
ForEach ($err in $error) {
Switch ($err) {
{$err -is [System.Management.Automation.ErrorRecord]} {
$hash = @{
Category = $err.categoryinfo.Category
Activity = $err.categoryinfo.Activity
Reason = $err.categoryinfo.Reason
Type = $err.GetType().ToString()
Exception = ($err.exception -split ": ")[1]
QualifiedError = $err.FullyQualifiedErrorId
CharacterNumber = $err.InvocationInfo.OffsetInLine
LineNumber = $err.InvocationInfo.ScriptLineNumber
Line = $err.InvocationInfo.Line
TargetObject = $err.TargetObject
}
}
Default {
$hash = @{
Category = $err.errorrecord.categoryinfo.category
Activity = $err.errorrecord.categoryinfo.Activity
Reason = $err.errorrecord.categoryinfo.Reason
Type = $err.GetType().ToString()
Exception = ($err.errorrecord.exception -split ": ")[1]
QualifiedError = $err.errorrecord.FullyQualifiedErrorId
CharacterNumber = $err.errorrecord.InvocationInfo.OffsetInLine
LineNumber = $err.errorrecord.InvocationInfo.ScriptLineNumber
Line = $err.errorrecord.InvocationInfo.Line
TargetObject = $err.errorrecord.TargetObject
}
}
}
$object = New-Object PSObject -Property $hash
$object.PSTypeNames.Insert(0,'ErrorInformation')
$object
}
}
}
#Add new server to GUI
Function Add-Server {
$computers = [Microsoft.VisualBasic.Interaction]::InputBox("Enter a server name or names. Separate servers with a comma (,) or semi-colon (;).", "Add Server/s")
If (-Not [System.String]::IsNullOrEmpty($computers)) {
[string[]]$computername = $computers -split ",|;"
ForEach ($computer in $computername) {
If (-NOT [System.String]::IsNullOrEmpty($computer) -AND -NOT $ComputerCache.Contains($Computer.Trim()) -AND -NOT $Exempt -contains $computer) {
[void]$ComputerCache.Add($Computer.Trim())
$clientObservable.Add((
New-Object PSObject -Property @{
Computer = ($computer).Trim()
Audited = 0 -as [int]
Installed = 0 -as [int]
InstallErrors = 0 -as [int]
Services = 0 -as [int]
Notes = $Null
}
))
Show-DebugState
}
}
}
}
#Remove server from GUI
Function Remove-Server {
$Servers = @($uiHash.Listview.SelectedItems)
ForEach ($server in $servers) {
$clientObservable.Remove($server)
$ComputerCache.Remove($Server.Computer)
}
$uiHash.ProgressBar.Maximum = $uiHash.Listview.ItemsSource.count
Show-DebugState
}
#Report Generation function
Function Start-Report {
Write-Debug ("Data: {0}" -f $uiHash.ReportComboBox.SelectedItem.Text)
Switch ($uiHash.ReportComboBox.SelectedItem.Text) {
"Audit CSV Report" {
If ($updateAudit.count -gt 0) {
$uiHash.StatusTextBox.Foreground = "Black"
$savedreport = Join-Path $reportpath "AuditReport.csv"
$updateAudit | Export-Csv $savedreport -NoTypeInformation
$uiHash.StatusTextBox.Text = "Report saved to $savedreport"
} Else {
$uiHash.StatusTextBox.Foreground = "Red"
$uiHash.StatusTextBox.Text = "No report to create!"
}
}
"Audit UI Report" {
If ($updateAudit.count -gt 0) {
$updateAudit | Out-GridView -Title 'Audit Report'
} Else {
$uiHash.StatusTextBox.Foreground = "Red"
$uiHash.StatusTextBox.Text = "No report to create!"
}
}
"Install CSV Report" {
If ($installAudit.count -gt 0) {
$uiHash.StatusTextBox.Foreground = "Black"
$savedreport = Join-Path $reportpath "InstallReport.csv"
$installAudit | Export-Csv $savedreport -NoTypeInformation
$uiHash.StatusTextBox.Text = "Report saved to $savedreport"
} Else {
$uiHash.StatusTextBox.Foreground = "Red"
$uiHash.StatusTextBox.Text = "No report to create!"
}
}
"Install UI Report" {
If ($installAudit.count -gt 0) {
$installAudit | Out-GridView -Title 'Install Report'
} Else {
$uiHash.StatusTextBox.Foreground = "Red"
$uiHash.StatusTextBox.Text = "No report to create!"
}
}
"Installed Updates CSV Report" {
If ($installedUpdates.count -gt 0) {
$uiHash.StatusTextBox.Foreground = "Black"
$savedreport = Join-Path $reportpath "InstalledUpdatesReport.csv"
$installedUpdates | Export-Csv $savedreport -NoTypeInformation
$uiHash.StatusTextBox.Text = "Report saved to $savedreport"
} Else {
$uiHash.StatusTextBox.Foreground = "Red"
$uiHash.StatusTextBox.Text = "No report to create!"
}
}
"Installed Updates UI Report" {
If ($installedUpdates.count -gt 0) {
$installedUpdates | Out-GridView -Title 'Installed Updates Report'
} Else {
$uiHash.StatusTextBox.Foreground = "Red"
$uiHash.StatusTextBox.Text = "No report to create!"
}
}
"Host File List" {
If ($uiHash.Listview.Items.count -gt 0) {
$uiHash.StatusTextBox.Foreground = "Black"
$savedreport = Join-Path $reportpath "hosts.txt"
$uiHash.Listview.DataContext | Select -Expand Computer | Out-File $savedreport
$uiHash.StatusTextBox.Text = "Report saved to $savedreport"
} Else {
$uiHash.StatusTextBox.Foreground = "Red"
$uiHash.StatusTextBox.Text = "No report to create!"
}
}
"Computer List Report" {
If ($uiHash.Listview.Items.count -gt 0) {
$uiHash.StatusTextBox.Foreground = "Black"
$savedreport = Join-Path $Global:ReportPath "serverlist.csv"
$uiHash.Listview.Items | Export-Csv -NoTypeInformation $savedreport
$uiHash.StatusTextBox.Text = "Report saved to $savedreport"
} Else {
$uiHash.StatusTextBox.Foreground = "Red"
$uiHash.StatusTextBox.Text = "No report to create!"
}
}
"Error UI Report" {Get-Error | Out-GridView -Title 'Error Report'}
"Services UI Report" {
If (@($servicesAudit).count -gt 0) {
$servicesAudit | Select @{L='Computername';E={$_.__Server}},Name,DisplayName,State,StartMode,ExitCode,Status | Out-GridView -Title 'Services Report'
} Else {
$uiHash.StatusTextBox.Foreground = "Red"
$uiHash.StatusTextBox.Text = "No report to create!"
}
}
"Services CSV Report" {
If (@($servicesAudit).count -gt 0) {
$uiHash.StatusTextBox.Foreground = "Black"
$savedreport = Join-Path $reportpath "ServicesReport.csv"
$servicesAudit | Select @{L='Computername';E={$_.__Server}},Name,DisplayName,State,StartMode,ExitCode,Status | Export-Csv $savedreport -NoTypeInformation
$uiHash.StatusTextBox.Text = "Report saved to $savedreport"
} Else {
$uiHash.StatusTextBox.Foreground = "Red"
$uiHash.StatusTextBox.Text = "No report to create!"
}
}
}
}
#start-RunJob function
Function Start-RunJob {
Write-Debug ("ComboBox {0}" -f $uiHash.RunOptionComboBox.Text)
$selectedItems = $uiHash.Listview.SelectedItems
If ($selectedItems.Count -gt 0) {
$uiHash.ProgressBar.Maximum = $selectedItems.count
$uiHash.Listview.ItemsSource | ForEach {$_.Notes = $Null}
If ($uiHash.RunOptionComboBox.Text -eq 'Install Patches') {
#region Install Patches
$uiHash.RunButton.IsEnabled = $False
$uiHash.StartImage.Source = "$pwd\Images\Start_locked.jpg"
$uiHash.CancelButton.IsEnabled = $True
$uiHash.CancelImage.Source = "$pwd\Images\Stop.jpg"
$uiHash.StatusTextBox.Foreground = "Black"
$uiHash.StatusTextBox.Text = "Installing Patches for all servers...Please Wait"
$uiHash.StartTime = (Get-Date)
[Float]$uiHash.ProgressBar.Value = 0
$scriptBlock = {
Param (
$Path,
$Computer,
$installAudit,
$uiHash
)
$uiHash.ListView.Dispatcher.Invoke("Normal",[action]{
$uiHash.Listview.Items.EditItem($Computer)
$computer.Notes = "Installing Patches"
$uiHash.Listview.Items.CommitEdit()
$uiHash.Listview.Items.Refresh()
})
Set-Location $path
. .\Scripts\Install-Patches.ps1
$clientInstall = @(Install-Patches -Computername $computer.computer)
$installAudit.AddRange($clientInstall) | Out-Null
$clientInstalledCount = @($clientInstall | Where {$_.Notes -notmatch "Failed to Install Patch|ERROR"}).Count
$clientInstalledErrorCount = @($clientInstall | Where {$_.Notes -match "Failed to Install Patch|ERROR"}).Count
$uiHash.ListView.Dispatcher.Invoke("Normal",[action]{
$uiHash.Listview.Items.EditItem($Computer)
If ($clientInstall[0].Title -eq "NA") {
$Computer.Installed = 0
} Else {
$Computer.Installed = $clientInstalledCount
$Computer.InstallErrors = $clientInstalledErrorCount
}
$Computer.Notes = "Completed"
$uiHash.Listview.Items.CommitEdit()
$uiHash.Listview.Items.Refresh()
})
$uiHash.ProgressBar.Dispatcher.Invoke("Normal",[action]{
$uiHash.ProgressBar.value++
})
$uiHash.Window.Dispatcher.Invoke("Normal",[action]{
#Check to see if find job
If ($uiHash.ProgressBar.value -eq $uiHash.ProgressBar.Maximum) {
$End = New-Timespan $uihash.StartTime (Get-Date)
$uiHash.StatusTextBox.Text = ("Completed in {0}" -f $end)
$uiHash.RunButton.IsEnabled = $True
$uiHash.StartImage.Source = "$pwd\Images\Start.jpg"
$uiHash.CancelButton.IsEnabled = $False
$uiHash.CancelImage.Source = "$pwd\Images\Stop_locked.jpg"
}
})
}
Write-Verbose ("Creating runspace pool and session states")
$sessionstate = [system.management.automation.runspaces.initialsessionstate]::CreateDefault()
$runspaceHash.runspacepool = [runspacefactory]::CreateRunspacePool(1, $maxConcurrentJobs, $sessionstate, $Host)
$runspaceHash.runspacepool.Open()
ForEach ($Computer in $selectedItems) {
$uiHash.Listview.Items.EditItem($Computer)
$computer.Notes = "Pending Patch Install"
$uiHash.Listview.Items.CommitEdit()
$uiHash.Listview.Items.Refresh()
#Create the powershell instance and supply the scriptblock with the other parameters
$powershell = [powershell]::Create().AddScript($ScriptBlock).AddArgument($Path).AddArgument($computer).AddArgument($installAudit).AddArgument($uiHash)
#Add the runspace into the powershell instance
$powershell.RunspacePool = $runspaceHash.runspacepool
#Create a temporary collection for each runspace
$temp = "" | Select-Object PowerShell,Runspace,Computer
$Temp.Computer = $Computer.computer
$temp.PowerShell = $powershell
#Save the handle output when calling BeginInvoke() that will be used later to end the runspace
$temp.Runspace = $powershell.BeginInvoke()
Write-Verbose ("Adding {0} collection" -f $temp.Computer)
$jobs.Add($temp) | Out-Null
}#endregion
} ElseIf ($uiHash.RunOptionComboBox.Text -eq 'Audit Patches') {
#region Audit Patches
$uiHash.RunButton.IsEnabled = $False
$uiHash.StartImage.Source = "$pwd\Images\Start_locked.jpg"
$uiHash.CancelButton.IsEnabled = $True
$uiHash.CancelImage.Source = "$pwd\Images\Stop.jpg"
$uiHash.StatusTextBox.Foreground = "Black"
$uiHash.StatusTextBox.Text = "Auditing Patches for all servers...Please Wait"
$Global:updatelayout = [Windows.Input.InputEventHandler]{ $uiHash.ProgressBar.UpdateLayout() }
$uiHash.StartTime = (Get-Date)
[Float]$uiHash.ProgressBar.Value = 0
$scriptBlock = {
Param (
$Path,
$Computer,
$updateAudit,
$uiHash
)
$uiHash.ListView.Dispatcher.Invoke("Normal",[action]{
$uiHash.Listview.Items.EditItem($Computer)
$computer.Notes = "Auditing Patches"
$uiHash.Listview.Items.CommitEdit()
$uiHash.Listview.Items.Refresh()
})
Set-Location $path
. .\Scripts\Get-PendingUpdates.ps1
$clientUpdate = @(Get-PendingUpdates -Computer $computer.computer)
$updateAudit.AddRange($clientUpdate) | Out-Null
$uiHash.ListView.Dispatcher.Invoke("Normal",[action]{
$uiHash.Listview.Items.EditItem($Computer)
If ($clientUpdate[0].Title -eq "NA") {
$Computer.Audited = 0
$Computer.Notes = "Completed"
} ElseIf ($clientUpdate[0].Title -eq "ERROR") {
$Computer.Audited = 0
$Computer.Notes = "Error with Audit"
} ElseIf ($clientUpdate[0].Title -eq "OFFLINE") {
$Computer.Audited = 0
$Computer.Notes = "Offline"
} Else {
$Computer.Audited = $clientUpdate.Count
$Computer.Notes = "Completed"
}
$uiHash.Listview.Items.CommitEdit()
$uiHash.Listview.Items.Refresh()
})
$uiHash.ProgressBar.Dispatcher.Invoke("Normal",[action]{
$uiHash.ProgressBar.value++
})
$uiHash.Window.Dispatcher.Invoke("Normal",[action]{
#Check to see if find job
If ($uiHash.ProgressBar.value -eq $uiHash.ProgressBar.Maximum) {
$End = New-Timespan $uihash.StartTime (Get-Date)
$uiHash.StatusTextBox.Text = ("Completed in {0}" -f $end)
$uiHash.RunButton.IsEnabled = $True
$uiHash.StartImage.Source = "$pwd\Images\Start.jpg"
$uiHash.CancelButton.IsEnabled = $False
$uiHash.CancelImage.Source = "$pwd\Images\Stop_locked.jpg"
}
})
}
Write-Verbose ("Creating runspace pool and session states")
$sessionstate = [system.management.automation.runspaces.initialsessionstate]::CreateDefault()
$runspaceHash.runspacepool = [runspacefactory]::CreateRunspacePool(1, $maxConcurrentJobs, $sessionstate, $Host)
$runspaceHash.runspacepool.Open()
ForEach ($Computer in $selectedItems) {
$uiHash.Listview.Items.EditItem($Computer)
$computer.Notes = "Pending Patch Audit"
$uiHash.Listview.Items.CommitEdit()
$uiHash.Listview.Items.Refresh()
#Create the powershell instance and supply the scriptblock with the other parameters
$powershell = [powershell]::Create().AddScript($ScriptBlock).AddArgument($Path).AddArgument($computer).AddArgument($updateAudit).AddArgument($uiHash)
#Add the runspace into the powershell instance
$powershell.RunspacePool = $runspaceHash.runspacepool
#Create a temporary collection for each runspace
$temp = "" | Select-Object PowerShell,Runspace,Computer
$Temp.Computer = $Computer.computer
$temp.PowerShell = $powershell
#Save the handle output when calling BeginInvoke() that will be used later to end the runspace
$temp.Runspace = $powershell.BeginInvoke()
Write-Verbose ("Adding {0} collection" -f $temp.Computer)
$jobs.Add($temp) | Out-Null
}#endregion
} ElseIf ($uiHash.RunOptionComboBox.Text -eq 'Reboot Systems') {
#region Reboot
If ((Show-RebootWarning) -eq "Yes") {
$uiHash.RunButton.IsEnabled = $False
$uiHash.StartImage.Source = "$pwd\Images\Start_locked.jpg"
$uiHash.CancelButton.IsEnabled = $True
$uiHash.CancelImage.Source = "$pwd\Images\Stop.jpg"
$uiHash.StatusTextBox.Foreground = "Black"
$uiHash.StatusTextBox.Text = "Rebooting Servers..."
$uiHash.StartTime = (Get-Date)
[Float]$uiHash.ProgressBar.Value = 0
$scriptBlock = {
Param (
$Computer,
$uiHash,
$Path
)
$uiHash.ListView.Dispatcher.Invoke("Normal",[action]{
$uiHash.Listview.Items.EditItem($Computer)
$computer.Notes = "Rebooting"
$uiHash.Listview.Items.CommitEdit()
$uiHash.Listview.Items.Refresh()
})
Set-Location $Path
If (Test-Connection -Computer $Computer.computer -count 1 -Quiet) {
Try {
Restart-Computer -ComputerName $Computer.computer -Force -ea stop
Do {
Start-Sleep -Seconds 2
Write-Verbose ("Waiting for {0} to shutdown..." -f $Computer.computer)
}
While ((Test-Connection -ComputerName $Computer.computer -Count 1 -Quiet))
Do {
Start-Sleep -Seconds 5
$i++
Write-Verbose ("{0} down...{1}" -f $Computer.computer, $i)
If($i -eq 60) {
Write-Warning ("{0} did not come back online from reboot!" -f $Computer.computer)
$connection = $False
}
}
While (-NOT(Test-Connection -ComputerName $Computer.computer -Count 1 -Quiet))
Write-Verbose ("{0} is back up" -f $Computer.computer)
$connection = $True
} Catch {
Write-Warning "$($Error[0])"
$connection = $False
}
}
$uiHash.ListView.Dispatcher.Invoke("Normal",[action]{
$uiHash.Listview.Items.EditItem($Computer)
If ($Connection) {
$Computer.Notes = "Online"
} ElseIf (-Not $Connection) {
$Computer.Notes = "Offline"
} Else {
$Computer.Notes = "Unknown"
}
$uiHash.Listview.Items.CommitEdit()
$uiHash.Listview.Items.Refresh()
})
$uiHash.ProgressBar.Dispatcher.Invoke("Normal",[action]{
$uiHash.ProgressBar.value++
})
$uiHash.Window.Dispatcher.Invoke("Normal",[action]{
#Check to see if find job
If ($uiHash.ProgressBar.value -eq $uiHash.ProgressBar.Maximum) {
$End = New-Timespan $uihash.StartTime (Get-Date)
$uiHash.StatusTextBox.Text = ("Completed in {0}" -f $end)
$uiHash.RunButton.IsEnabled = $True
$uiHash.StartImage.Source = "$pwd\Images\Start.jpg"
$uiHash.CancelButton.IsEnabled = $False
$uiHash.CancelImage.Source = "$pwd\Images\Stop_locked.jpg"
}
})
}
Write-Verbose ("Creating runspace pool and session states")
$sessionstate = [system.management.automation.runspaces.initialsessionstate]::CreateDefault()
$runspaceHash.runspacepool = [runspacefactory]::CreateRunspacePool(1, $maxRebootJobs, $sessionstate, $Host)
$runspaceHash.runspacepool.Open()
ForEach ($Computer in $selectedItems) {
$uiHash.Listview.Items.EditItem($Computer)
$computer.Notes = "Pending Reboot"
$uiHash.Listview.Items.CommitEdit()
$uiHash.Listview.Items.Refresh()
#Create the powershell instance and supply the scriptblock with the other parameters
$powershell = [powershell]::Create().AddScript($ScriptBlock).AddArgument($computer).AddArgument($uiHash).AddArgument($Path)
#Add the runspace into the powershell instance
$powershell.RunspacePool = $runspaceHash.runspacepool
#Create a temporary collection for each runspace
$temp = "" | Select-Object PowerShell,Runspace,Computer
$Temp.Computer = $Computer.computer
$temp.PowerShell = $powershell
#Save the handle output when calling BeginInvoke() that will be used later to end the runspace
$temp.Runspace = $powershell.BeginInvoke()
Write-Verbose ("Adding {0} collection" -f $temp.Computer)
$jobs.Add($temp) | Out-Null
}
}#endregion
} ElseIf ($uiHash.RunOptionComboBox.Text -eq 'Ping Sweep') {
#region PingSweeps
$uiHash.RunButton.IsEnabled = $False
$uiHash.StartImage.Source = "$pwd\Images\Start_locked.jpg"
$uiHash.CancelButton.IsEnabled = $True
$uiHash.CancelImage.Source = "$pwd\Images\Stop.jpg"
$uiHash.StatusTextBox.Foreground = "Black"
$uiHash.StatusTextBox.Text = "Checking server connection..."
$uiHash.StartTime = (Get-Date)
[Float]$uiHash.ProgressBar.Value = 0
$scriptBlock = {
Param (
$Computer,
$uiHash,
$Path
)
$uiHash.ListView.Dispatcher.Invoke("Normal",[action]{
$uiHash.Listview.Items.EditItem($Computer)
$computer.Notes = "Checking connection"
$uiHash.Listview.Items.CommitEdit()
$uiHash.Listview.Items.Refresh()
})
Set-Location $Path
$Connection = (Test-Connection -ComputerName $Computer.computer -Count 1 -Quiet)
$uiHash.ListView.Dispatcher.Invoke("Background",[action]{
$uiHash.Listview.Items.EditItem($Computer)
If ($Connection) {
$Computer.Notes = "Online"
} ElseIf (-Not $Connection) {
$Computer.Notes = "Offline"
} Else {
$Computer.Notes = "Unknown"
}
$uiHash.Listview.Items.CommitEdit()
$uiHash.Listview.Items.Refresh()
})
$uiHash.ProgressBar.Dispatcher.Invoke("Normal",[action]{
$uiHash.ProgressBar.value++
})
$uiHash.Window.Dispatcher.Invoke("Normal",[action]{
#Check to see if find job
If ($uiHash.ProgressBar.value -eq $uiHash.ProgressBar.Maximum) {
$End = New-Timespan $uihash.StartTime (Get-Date)
$uiHash.StatusTextBox.Text = ("Completed in {0}" -f $end)
$uiHash.RunButton.IsEnabled = $True
$uiHash.StartImage.Source = "$pwd\Images\Start.jpg"
$uiHash.CancelButton.IsEnabled = $False
$uiHash.CancelImage.Source = "$pwd\Images\Stop_locked.jpg"
}
})
}
Write-Verbose ("Creating runspace pool and session states")
$sessionstate = [system.management.automation.runspaces.initialsessionstate]::CreateDefault()
$runspaceHash.runspacepool = [runspacefactory]::CreateRunspacePool(1, $maxConcurrentJobs, $sessionstate, $Host)
$runspaceHash.runspacepool.Open()
ForEach ($Computer in $selectedItems) {
$uiHash.Listview.Items.EditItem($Computer)
$computer.Notes = "Pending Network Test"
$uiHash.Listview.Items.CommitEdit()
$uiHash.Listview.Items.Refresh()
#Create the powershell instance and supply the scriptblock with the other parameters
$powershell = [powershell]::Create().AddScript($ScriptBlock).AddArgument($computer).AddArgument($uiHash).AddArgument($Path)
#Add the runspace into the powershell instance
$powershell.RunspacePool = $runspaceHash.runspacepool
#Create a temporary collection for each runspace
$temp = "" | Select-Object PowerShell,Runspace,Computer
$Temp.Computer = $Computer.computer
$temp.PowerShell = $powershell
#Save the handle output when calling BeginInvoke() that will be used later to end the runspace
$temp.Runspace = $powershell.BeginInvoke()
Write-Verbose ("Adding {0} collection" -f $temp.Computer)
$jobs.Add($temp) | Out-Null
}
#endregion
} ElseIf ($uiHash.RunOptionComboBox.Text -eq 'Check Pending Reboot') {
#region Check Pending Reboot
$uiHash.RunButton.IsEnabled = $False
$uiHash.StartImage.Source = "$pwd\Images\Start_locked.jpg"
$uiHash.CancelButton.IsEnabled = $True
$uiHash.CancelImage.Source = "$pwd\Images\Stop.jpg"
$uiHash.StatusTextBox.Foreground = "Black"
$uiHash.StatusTextBox.Text = "Checking for servers with a pending reboot..."
$uiHash.StartTime = (Get-Date)
[Float]$uiHash.ProgressBar.Value = 0
$scriptBlock = {
Param (
$Computer,
$uiHash,
$Path
)
$uiHash.ListView.Dispatcher.Invoke("Normal",[action]{
$uiHash.Listview.Items.EditItem($Computer)
$computer.Notes = "Checking for pending reboot"
$uiHash.Listview.Items.CommitEdit()
$uiHash.Listview.Items.Refresh()
})
Set-Location $Path
. .\Scripts\Get-ComputerRebootState.ps1
$clientRebootRequired = Get-ComputerRebootState -Computer $Computer.computer
$uiHash.ListView.Dispatcher.Invoke("Background",[action]{
$uiHash.Listview.Items.EditItem($Computer)
If ($clientRebootRequired.RebootRequired -eq $True) {
$Computer.Notes = "Reboot Required"
} ElseIf ($clientRebootRequired.RebootRequired -eq $False) {
$Computer.Notes = "No Reboot Required"
} ElseIf ($clientRebootRequired.RebootRequired -eq "NA") {
$Computer.Notes = "Unable to determine reboot state"
} ElseIf ($clientRebootRequired.RebootRequired -eq "Offline") {
$Computer.Notes = "Offline"
}
$uiHash.Listview.Items.CommitEdit()
$uiHash.Listview.Items.Refresh()
})
$uiHash.ProgressBar.Dispatcher.Invoke("Normal",[action]{
$uiHash.ProgressBar.value++
})
$uiHash.Window.Dispatcher.Invoke("Normal",[action]{
#Check to see if find job
If ($uiHash.ProgressBar.value -eq $uiHash.ProgressBar.Maximum) {
$End = New-Timespan $uihash.StartTime (Get-Date)
$uiHash.StatusTextBox.Text = ("Completed in {0}" -f $end)
$uiHash.RunButton.IsEnabled = $True
$uiHash.StartImage.Source = "$pwd\Images\Start.jpg"
$uiHash.CancelButton.IsEnabled = $False
$uiHash.CancelImage.Source = "$pwd\Images\Stop_locked.jpg"
}
})
}
Write-Verbose ("Creating runspace pool and session states")
$sessionstate = [system.management.automation.runspaces.initialsessionstate]::CreateDefault()
$runspaceHash.runspacepool = [runspacefactory]::CreateRunspacePool(1, $maxConcurrentJobs, $sessionstate, $Host)
$runspaceHash.runspacepool.Open()
ForEach ($Computer in $selectedItems) {
$uiHash.Listview.Items.EditItem($Computer)
$computer.Notes = "Pending Reboot Check"
$uiHash.Listview.Items.CommitEdit()
$uiHash.Listview.Items.Refresh()
#Create the powershell instance and supply the scriptblock with the other parameters
$powershell = [powershell]::Create().AddScript($ScriptBlock).AddArgument($computer).AddArgument($uiHash).AddArgument($Path)
#Add the runspace into the powershell instance
$powershell.RunspacePool = $runspaceHash.runspacepool
#Create a temporary collection for each runspace
$temp = "" | Select-Object PowerShell,Runspace,Computer
$Temp.Computer = $Computer.computer
$temp.PowerShell = $powershell
#Save the handle output when calling BeginInvoke() that will be used later to end the runspace
$temp.Runspace = $powershell.BeginInvoke()
Write-Verbose ("Adding {0} collection" -f $temp.Computer)
$jobs.Add($temp) | Out-Null
}#endregion
} ElseIf ($uiHash.RunOptionComboBox.Text -eq 'Services Check') {
#region Check Services
$uiHash.RunButton.IsEnabled = $False
$uiHash.StartImage.Source = "$pwd\Images\Start_locked.jpg"
$uiHash.CancelButton.IsEnabled = $True
$uiHash.CancelImage.Source = "$pwd\Images\Stop.jpg"
$uiHash.StatusTextBox.Foreground = "Black"
$uiHash.StatusTextBox.Text = "Checking for Non-Running Automatic Services..."
$uiHash.StartTime = (Get-Date)
[Float]$uiHash.ProgressBar.Value = 0
$scriptBlock = {
Param (
$Computer,
$uiHash,
$Path,
$servicesAudit
)
$uiHash.ListView.Dispatcher.Invoke("Normal",[action]{
$uiHash.Listview.Items.EditItem($Computer)
$computer.Notes = "Checking for non-running services set to Auto"
$uiHash.Listview.Items.CommitEdit()
$uiHash.Listview.Items.Refresh()
})
Clear-Variable queryError -ErrorAction SilentlyContinue
Set-Location $Path
If (Test-Connection -ComputerName $computer.computer -Count 1 -Quiet) {
Try {
$wmi = @{
ErrorAction = 'Stop'
Computername = $computer.computer
Query = "Select __Server,Name,DisplayName,State,StartMode,ExitCode,Status FROM Win32_Service WHERE StartMode='Auto' AND State!='Running'"
}
$services = @(Get-WmiObject @wmi)
} Catch {
$queryError = $_.Exception.Message
}
} Else {
$queryError = "Offline"
}
If ($services.count -gt 0) {
$servicesAudit.AddRange($services) | Out-Null
}
$uiHash.ListView.Dispatcher.Invoke("Background",[action]{
$uiHash.Listview.Items.EditItem($Computer)
$Computer.Services = $services.count
If ($queryError) {
$Computer.notes = $queryError
} Else {
$Computer.notes = 'Completed'
}
$uiHash.Listview.Items.CommitEdit()
$uiHash.Listview.Items.Refresh()
})
$uiHash.ProgressBar.Dispatcher.Invoke("Normal",[action]{
$uiHash.ProgressBar.value++
})
$uiHash.Window.Dispatcher.Invoke("Normal",[action]{
#Check to see if find job
If ($uiHash.ProgressBar.value -eq $uiHash.ProgressBar.Maximum) {
$End = New-Timespan $uihash.StartTime (Get-Date)
$uiHash.StatusTextBox.Text = ("Completed in {0}" -f $end)
$uiHash.RunButton.IsEnabled = $True
$uiHash.StartImage.Source = "$pwd\Images\Start.jpg"
$uiHash.CancelButton.IsEnabled = $False
$uiHash.CancelImage.Source = "$pwd\Images\Stop_locked.jpg"
}
})
}
Write-Verbose ("Creating runspace pool and session states")
$sessionstate = [system.management.automation.runspaces.initialsessionstate]::CreateDefault()
$runspaceHash.runspacepool = [runspacefactory]::CreateRunspacePool(1, $maxConcurrentJobs, $sessionstate, $Host)
$runspaceHash.runspacepool.Open()
ForEach ($Computer in $selectedItems) {
$uiHash.Listview.Items.EditItem($Computer)
$computer.Notes = "Pending Service Check"
$uiHash.Listview.Items.CommitEdit()
$uiHash.Listview.Items.Refresh()
#Create the powershell instance and supply the scriptblock with the other parameters
$powershell = [powershell]::Create().AddScript($ScriptBlock).AddArgument($computer).AddArgument($uiHash).AddArgument($Path).AddArgument($servicesAudit)
#Add the runspace into the powershell instance
$powershell.RunspacePool = $runspaceHash.runspacepool
#Create a temporary collection for each runspace
$temp = "" | Select-Object PowerShell,Runspace,Computer
$Temp.Computer = $Computer.computer
$temp.PowerShell = $powershell
#Save the handle output when calling BeginInvoke() that will be used later to end the runspace
$temp.Runspace = $powershell.BeginInvoke()
Write-Verbose ("Adding {0} collection" -f $temp.Computer)
$jobs.Add($temp) | Out-Null
}#endregion
}
} Else {
$uiHash.StatusTextBox.Foreground = "Red"
$uiHash.StatusTextBox.Text = "No server/s selected!"
}
}
Function Open-FileDialog {
$dlg = new-object microsoft.win32.OpenFileDialog
$dlg.DefaultExt = "*.txt"
$dlg.Filter = "Text Files |*.txt;*.log"
$dlg.InitialDirectory = $path
[void]$dlg.showdialog()
Write-Output $dlg.FileName
}
Function Open-DomainDialog {
$domain = [Microsoft.VisualBasic.Interaction]::InputBox("Enter the LDAP path for the Domain or press OK to use the default domain.",
"Domain Query", "$(([adsisearcher]'').SearchRoot.distinguishedName)")
If (-Not [string]::IsNullOrEmpty($domain)) {
Write-Output $domain
}
}
#Build the GUI
[xml]$xaml = @"
<Window
xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
x:Name='Window' Title='PowerShell Patch/Audit Utility' WindowStartupLocation = 'CenterScreen'
Width = '880' Height = '575' ShowInTaskbar = 'True'>
<Window.Background>
<LinearGradientBrush StartPoint='0,0' EndPoint='0,1'>
<LinearGradientBrush.GradientStops> <GradientStop Color='#C4CBD8' Offset='0' /> <GradientStop Color='#E6EAF5' Offset='0.2' />
<GradientStop Color='#CFD7E2' Offset='0.9' /> <GradientStop Color='#C4CBD8' Offset='1' /> </LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Window.Background>
<Window.Resources>
<DataTemplate x:Key="HeaderTemplate">
<DockPanel>
<TextBlock FontSize="10" Foreground="Green" FontWeight="Bold" >
<TextBlock.Text>
<Binding/>
</TextBlock.Text>
</TextBlock>
</DockPanel>
</DataTemplate>
</Window.Resources>
<Grid x:Name = 'Grid' ShowGridLines = 'false'>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height = 'Auto'/>
<RowDefinition Height = 'Auto'/>
<RowDefinition Height = '*'/>
<RowDefinition Height = 'Auto'/>
<RowDefinition Height = 'Auto'/>
<RowDefinition Height = 'Auto'/>
</Grid.RowDefinitions>
<Menu Width = 'Auto' HorizontalAlignment = 'Stretch' Grid.Row = '0'>
<Menu.Background>
<LinearGradientBrush StartPoint='0,0' EndPoint='0,1'>
<LinearGradientBrush.GradientStops> <GradientStop Color='#C4CBD8' Offset='0' /> <GradientStop Color='#E6EAF5' Offset='0.2' />
<GradientStop Color='#CFD7E2' Offset='0.9' /> <GradientStop Color='#C4CBD8' Offset='1' /> </LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Menu.Background>
<MenuItem x:Name = 'FileMenu' Header = '_File'>
<MenuItem x:Name = 'RunMenu' Header = '_Run' ToolTip = 'Initiate Run operation' InputGestureText ='F5'> </MenuItem>
<MenuItem x:Name = 'GenerateReportMenu' Header = 'Generate R_eport' ToolTip = 'Generate Report' InputGestureText ='F8'/>
<Separator />
<MenuItem x:Name = 'OptionMenu' Header = '_Options' ToolTip = 'Open up options window.' InputGestureText ='Ctrl+O'/>
<Separator />
<MenuItem x:Name = 'ExitMenu' Header = 'E_xit' ToolTip = 'Exits the utility.' InputGestureText ='Ctrl+E'/>
</MenuItem>
<MenuItem x:Name = 'EditMenu' Header = '_Edit'>
<MenuItem x:Name = 'SelectAllMenu' Header = 'Select _All' ToolTip = 'Selects all rows.' InputGestureText ='Ctrl+A'/>
<Separator />
<MenuItem x:Name = 'ClearErrorMenu' Header = 'Clear ErrorLog' ToolTip = 'Clears error log.'> </MenuItem>
<MenuItem x:Name = 'ClearAllMenu' Header = 'Clear All' ToolTip = 'Clears everything on the WSUS utility.'/>
</MenuItem>
<MenuItem x:Name = 'ActionMenu' Header = '_Action'>
<MenuItem Header = 'Reports'>
<MenuItem x:Name = 'ClearAuditReportMenu' Header = 'Clear Audit Report' ToolTip = 'Clears the current report.'/>
<MenuItem x:Name = 'ClearInstallReportMenu' Header = 'Clear Install Report' ToolTip = 'Clears the current report.'/>
<MenuItem x:Name = 'ClearInstalledUpdateMenu' Header = 'Clear Installed Update Report' ToolTip = 'Clears the installed update report.'/>
</MenuItem>
<MenuItem Header = 'Server List'>
<MenuItem x:Name = 'ClearServerListMenu' Header = 'Clear Server List' ToolTip = 'Clears the server list.'/>
<MenuItem x:Name = 'ClearServerListNotesMenu' Header = 'Clear Server List Notes' ToolTip = 'Clears the server list notes column.'/>
<MenuItem x:Name = 'OfflineHostsMenu' Header = 'Remove Offline Servers' ToolTip = 'Removes all offline hosts from Server List'/>
<MenuItem x:Name = 'ResetDataMenu' Header = 'Reset Computer List Data' ToolTip = 'Resets the audit and patch data on Server List'/>
</MenuItem>
<Separator />
<MenuItem x:Name = 'HostListMenu' Header = 'Create Host List' ToolTip = 'Creates a list of all servers and saves to a text file.'/>
<MenuItem x:Name = 'ServerListReportMenu' Header = 'Create Server List Report'
ToolTip = 'Creates a CSV file listing the current Server List.'/>
<Separator/>
<MenuItem x:Name = 'ViewErrorMenu' Header = 'View ErrorLog' ToolTip = 'Clears error log.'/>
</MenuItem>
<MenuItem x:Name = 'HelpMenu' Header = '_Help'>
<MenuItem x:Name = 'AboutMenu' Header = '_About' ToolTip = 'Show the current version and other information.'> </MenuItem>
<MenuItem x:Name = 'HelpFileMenu' Header = 'WSUS Utility _Help'
ToolTip = 'Displays a help file to use the WSUS Utility.' InputGestureText ='F1'> </MenuItem>
</MenuItem>
</Menu>
<ToolBarTray Grid.Row = '1' Grid.Column = '0'>
<ToolBarTray.Background>
<LinearGradientBrush StartPoint='0,0' EndPoint='0,1'>
<LinearGradientBrush.GradientStops> <GradientStop Color='#C4CBD8' Offset='0' /> <GradientStop Color='#E6EAF5' Offset='0.2' />
<GradientStop Color='#CFD7E2' Offset='0.9' /> <GradientStop Color='#C4CBD8' Offset='1' /> </LinearGradientBrush.GradientStops>
</LinearGradientBrush>