-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathPoSh-EasyWin.ps1
1964 lines (1663 loc) · 221 KB
/
PoSh-EasyWin.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
<#
.SYNOPSIS
PoSh-EasyWin is a primarily a domain-wide host querying tool and provides easy viewing of queried
data via a filterable table and charts... plus much, much more.
.DESCRIPTION
_____ ____ _ _____ __ __ _
| _ \ ___ / ___| | |__ | ____| __ _ ___ _ _\ \ / /(_) _ __
| |_) |/ _ \\___ \ | '_ \ _____ | _| / _` |/ __|| | | |\ \ /\ / / | || '_ \
| __/| (_) |___) || | | ||_____|| |___| (_| |\__ \| |_| | \ V V / | || | | |
|_| \___/|____/ |_| |_| |_____|\__,_||___/ \__, | \_/\_/ |_||_| |_|
|___/
==================================================================================
PoSh-EasyWin: PowerShell - Endpoint Analysis Solution Your Windows Intranet Needs!
I know, I know-it's over the top... but who doesn't love tools with acronym names?
==================================================================================
File Name : PoSh-EasyWin.ps1
Version : Version 7.2.1
Updated : 01 Mar 2022
Created : 21 Aug 2018
Requirements : PowerShell v6.0+ - PowerShell Core is not supported
- GUI Windows.System.Forms
v5.1 - PSWriteHTML Module support
- Fully tested
v4.0 - The use of Copy-Item -Session
- Partially Tested
v3.0 - Splatting Arguments
- PowerShell Charts support
- Limited testing
v2.0 - Not supported, requres splatting
: WinRM HTTP - TCP/5985 Windows 7+ ( 80 Vista-)
HTTPS - TCP/5986 Windows 7+ (443 Vista-)
Endpoint Listener - TCP/47001
: DCOM RPC - TCP/135 and dynamic ports, typically:
TCP 49152-65535 (Windows Vista, Server 2008 and above)
TCP 1024 -65535 (Windows NT4, Windows 2000, Windows 2003)
Optional : PsExec.exe, Procmon.exe, Sysmon.exe,
etl2pcapng.exe, kitty.exe, plink.exe, chainsaw.exe, WxTCmd.exe
Author : Daniel S. Komnick (high101bro)
Email : [email protected]
Website : https://github.com/high101bro/PoSh-EasyWin
PoSh-EasyWin is the Endpoint Analysis Solution Your Windows Intranet Needs that provides a
simple user interface to execute any number of commands against any number of computers within
a network, access hosts, manage data, and analyze their results.
Though this may look like a program, it is still a script that has a GUI interface built
using the .Net Framework and WinForms. So when it's conducting queries, the GUI will be
unresponsive to user interaction even though you are able to view status and timer updates.
A few ways to run the script if you're unable to:
- Unblock-File if downloaded from the internet, Windows automatically blocks them as a security precatuion
You may have to use the Unblock-File cmdlet to be able to run the script.
- For addtional info on: Get-Help Unblock-File
How to Unblock the file:
- Unblock-File -Path .\PoSh-EasyWin.ps1
- Get-ChildItem -Path C:\Path\To\PoSh-Easywin -Recurse | Unblock-File
- Update Execution Policy locally
Open a PowerShell terminal with Administrator privledges
- Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process
- Get-ExecutionPolicy -List
- Update Execution Policy via GPO
Open the GPO for editing. In the GPO editor, select:
- Computer Configuration > Policies > Administrative Templates > Windows Components > Windows PowerShell
- Right-click "Turn on script execution", then select "Edit"
- In the winodws that appears, click on "Enabled" radio button
- Under "Execution Policy", select "Allow All Scripts"
- Click on "Ok", then close the GPO Editor
- Push out GPO Updates, or on the computer's powershell/cmd terminal, type in `"gpupdate /force"
Copyright (C) 2018 Daniel S Komnick
This program is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program.
It is located in the 'GPLv3 - GNU General Public License.txt' file in the Dependencies folder.
If not, see <https://www.gnu.org/licenses/>.
Credits:
Learned a lot and referenced code from sources like Microsoft Technet, PowerShell Gallery, StackOverflow, and a numerous other websites.
That said, I didn't track all sites and individuals that deserve credit. In the unlikely event you believe you do, please notify me.
.EXAMPLE
Example 1
All PoSh-EasyWin PowerShell scripts are signed, you can import the public certificate and run them.
The script will normally be blocked from execution.
PS C:\PoSh-EasyWin> .\PoSh-EasyWin.ps1
How to check the execution policy.
PS C:\PoSh-EasyWin> Get-ExecutionPolicy
How to import the certificate to allow for exection of signed scripts
PS C:\PoSh-EasyWin> Import-Certificate -FilePath ".\PoSh-EasyWin_Public_Certificate.cer" -CertStoreLocation Cert:\CurrentUser\Root
How to check the authenticode signature.
PS C:\PoSh-EasyWin> Get-AuthenticodeSignature .\PoSh-EasyWin.ps1
How to set the execution policy to either RemoteSigned or AllSigned. Either method will work, though AllSigned will prompt you with info.
PS C:\PoSh-EasyWin> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
PS C:\PoSh-EasyWin> Set-ExecutionPolicy -ExecutionPolicy AllSigned
# The script should run now.
PS C:\PoSh-EasyWin> .\PoSh-EasyWin.ps1
.EXAMPLE
Example 2
Scripts downloaded from the internet are blocked for execution as a Windodws' security precaution. If there is an error with Example 1, or you do not want to import PoSh-EasyWin's public certificate, you can do the following:
Unblock-File .\PoSh-EasyWin.ps1
.\PoSh-EasyWin.ps1
-or
Get-ChildItem -Path C:\Path\To\PoSh-Easywin -Recurse | Unblock-File
.\PoSh-EasyWin.ps1
.EXAMPLE
This will run PoSh-EasyWin.ps1 and provide prompts that will tailor your collection.
PowerShell.exe -ExecutionPolicy ByPass -NoProfile -File .\PoSh-EasyWin.ps1
.LINK
https://github.com/high101bro/PoSh-EasyWin
.NOTES
None
#>
[CmdletBinding(
DefaultParameterSetName='GUI',
HelpURI='https://github.com/high101bro/PoSh-EasyWin',
PositionalBinding = $true)]
param (
[Parameter(
Mandatory=$false,
HelpMessage="Skips the terminal privledge elevation check to run with higher permissions.")]
[switch]$SkipEvelationCheck,
[Parameter(
Mandatory=$false,
HelpMessage="Launches PoSh-EasyWin without hiding the parent PowerShell Terminal.")]
[switch]$ShowTerminal,
[Parameter(
Mandatory=$false,
ParameterSetName="GUI",
HelpMessage="The default font used in the GUI is Courier, but the following fonts also valdated.")]
[ValidateSet('Calibri','Courier','Arial')]
# This this validation set is expanded, ensure that larger fonts don't cause words to be truncated in the GUI
[ValidateNotNull()]
[string]$Font = "Courier"
)
# Keycodes
# https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.keys?view=net-5.0
# Font: Display --> Black Ops One
# https://flamingtext.com/logo/Design-Style
# https://www11.flamingtext.com/net-fu/dynamic.cgi?script=style-logo&text=PoSh-EasyWin&fontname=Black+Ops+One&fillTextColor=%23006fff&fillOutlineColor=%2320d
# Generates the GUI and contains the majority of the script
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
#============================================================================================================================================================
# Variables
#============================================================================================================================================================
$ErrorActionPreference = "SilentlyContinue"
# Script Launch Time - This in placed within both the title of the Main PoSh-EasyWin form and the title of the System Tray Notification
# Useful if multiple instances of PoSh-EasyWin are launched and you want to use the Abort/Reload or Exit Tool buttons on the corrent instance
$InitialScriptLoadTime = Get-Date
# The path of PoSh-EasyWin when executed
$PewScriptPath = $myinvocation.mycommand.definition
$PewScript = "& '$PewScriptPath'"
$PewScriptProcessId = [System.Diagnostics.Process]::GetCurrentProcess().Id
# Initial Size of PoSh-EasyWin. This is modified against the $FormSale value selected during setup
$FormOriginalWidth = 1435
$FormOriginalHeight = 685
# Location PoSh-EasyWin will save files
$PewRoot = $PSScriptRoot #Deprecated# Split-Path -parent $MyInvocation.MyCommand.Definition
$PewUserData = "$PewRoot\User Data"
if (-not (Test-Path $PewUserData )) {New-Item -ItemType Directory -Path $PewUserData -Force}
$PewLogFile = "$PewUserData\Log File.txt"
$CredentialManagementPath = "$PewUserData\Credential Management\"
$EndpointTreeNodeFileSave = "$PewUserData\TreeView Data - Endpoint.csv"
$AccountsTreeNodeFileSave = "$PewUserData\TreeView Data - Accounts.csv"
$CommandsUserAddedWinRM = "$PewUserData\Commands - User Added WinRM.csv"
$CommandsUserAddedSSH = "$PewUserData\Commands - User Added SSH.csv"
$CommandsCustomGrouped = "$PewUserData\Commands - Custom Group Commands.xml"
$PewOpNotes = "$PewUserData\OpNotes.txt"
$PewSettings = "$PewUserData\Settings"
$ActiveDirectoryEndpoint = "$PewSettings\Active Directory Hostname.txt"
# Name of Collected Data Directory
$PewCollectedData = "$PewUserData\Collected Data"
if (-not (Test-Path $PewCollectedData )) { New-Item -ItemType Directory -Path $PewCollectedData -Force }
# Location of separate queries
$CollectedDataTimeStamp = "$PewCollectedData\$((Get-Date).ToString('yyyy-MM-dd HH.mm.ss'))"
$script:SaveLocation = $CollectedDataTimeStamp
#$script:SaveLocation = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)\Collected Data\$((Get-Date).ToString('yyyy-MM-dd HH.mm.ss'))"
$DemoData = "$PewRoot\Examples\Demo Data"
$EndpointTreeNodeFileSaveDemo = "$DemoData\TreeView Data - Endpoint.csv"
$AccountsTreeNodeFileSaveDemo = "$DemoData\TreeView Data - Accounts.csv"
$CommandsUserAddedWinRMDemo = "$DemoData\Commands - User Added WinRM.csv"
$CommandsUserAddedSSHDemo = "$DemoData\Commands - User Added SSH.csv"
$CommandsCustomGroupedDemo = "$DemoData\Commands - Custom Group Commands.xml"
$Dependencies = "$PewRoot\Dependencies"
$CommandsAndScripts = "$Dependencies\Commands & Scripts"
$CommandsEndpoint = "$CommandsAndScripts\Commands - Endpoint.csv"
$CommandsActiveDirectory = "$CommandsAndScripts\Commands - Active Directory.csv"
$PSWriteHTMLDirectory = "$Dependencies\Code\PSWriteHTML"
# Location of Event Logs Commands
$CommandsEventLogsDirectory = "$Dependencies\Event Log Info"
# CSV file of Event IDs
$EventIDsFile = "$CommandsEventLogsDirectory\Event IDs.csv"
# CSV file from Microsoft detailing Event IDs to Monitor
$EventLogsWindowITProCenter = "$CommandsEventLogsDirectory\Individual Selection\Event Logs to Monitor - Window IT Pro Center.csv"
# Location of External Programs directory
$ExternalPrograms = "$Dependencies\Executables"
$PsExecPath = "$ExternalPrograms\PsExec.exe"
$kitty_ssh_client = "$ExternalPrograms\KiTTY\kitty-0.74.4.7.exe"
$plink_ssh_client = "$ExternalPrograms\plink.exe"
$TagAutoListFile = "$Dependencies\Tags - Auto Populate.txt"
$CustomPortsToScan = "$Dependencies\Custom Ports To Scan.txt"
$EasyWinIcon = "$Dependencies\Images\Icons\favicon.ico"
$high101bro_image = "$Dependencies\Images\high101bro Logo Color Transparent.png"
# Send Files listbox value store
$script:SendFilesValueStoreListBox = @()
# Used to track the number of previous queries selected
$script:PreviousQueryCount = 0
# Keeps track of the number of RPC protocol commands selected, if the value is ever greater than one, it'll set the collection mode to 'Monitor Jobs'
$script:RpcCommandCount = 0
# Maintains the count of all the queries selected
$script:SectionQueryCount = 0
function Update-QueryCount {
if ($this.checked){$script:SectionQueryCount++}
else {$script:SectionQueryCount--}
}
# Creates Shortcut for PoSh-EasyWin on Desktop
$FileToShortCut = $($myinvocation.mycommand.definition)
$ShortcutDestination = "C:\Users\$($env:USERNAME)\Desktop\PoSh-EasyWin.lnk"
if (-not (Test-Path $ShortcutDestination)) {
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutDestination)
$Shortcut.TargetPath = $FileToShortCut
$Shortcut.IconLocation = $EasyWinIcon
$Shortcut.Save()
}
# Check if the script is running with Administrator Privlieges, if not it will attempt to re-run and prompt for credentials
# Not Using the following commandline, but rather the script below
# Note: Unable to . source this code from another file or use the call '&' operator to use as external cmdlet; it won't run the new terminal/GUI as Admin
<# #Requires -RunAsAdministrator #>
If (-NOT $SkipEvelationCheck -and -NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
$ElevateShell = [System.Windows.Forms.MessageBox]::Show("PoSh-EasyWin is writen in PowerShell and makes use of the .NET Framwork and WinForms to generate the user interface.`n`nIf you experience performance, user interface, or remoting issues, trying to run the tool with elevated permissions often helps. You can create and use alternate credentials for remoting within the Credential Management section.`n`nUse the -SkipElevationCheck if you want to avoid seeing this prompt.`n`nWould you like to relaunch this tool using administrator privileges.","PoSh-EasyWin",'YesNoCancel',"Warning")
switch ($ElevateShell) {
'Yes'{
if ($ShowTerminal) { Start-Process PowerShell.exe -Verb runAs -ArgumentList $PewScript }
else { Start-Process PowerShell.exe -Verb runAs -ArgumentList $PewScript -WindowStyle Hidden }
exit
}
'No' {
if ($ShowTerminal) { Start-Process PowerShell.exe -ArgumentList "$PewScript -SkipEvelationCheck" }
else { Start-Process PowerShell.exe -ArgumentList "$PewScript -SkipEvelationCheck" -WindowStyle Hidden }
exit
}
'Cancel' {exit}
}
}
elseif (-NOT $SkipEvelationCheck) {
if ($ShowTerminal) { Start-Process PowerShell.exe -Verb runAs -ArgumentList "$PewScript -SkipEvelationCheck" }
else { Start-Process PowerShell.exe -Verb runAs -ArgumentList "$PewScript -SkipEvelationCheck" -WindowStyle Hidden }
exit
}
elseif ($SkipEvelationCheck -and ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Host "`nThe " -ForegroundColor Green -NoNewline
Write-Host "-SkipElevationCheck " -NoNewline
Write-Host "parameter is not needed if the terminal used already has elevated permissions.`n" -ForegroundColor Green
}
$FormAdminCheck = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
. "$Dependencies\Code\Main\Import-FunctionsForSetup.ps1"
if (-Not (Test-Path $PewSettings)){New-Item -ItemType Directory $PewSettings | Out-Null}
# Logs what account ran the script and when
Write-LogEntry -LogFile $PewLogFile -NoTargetComputer -Message "===================================================================================================="
Write-LogEntry -LogFile $PewLogFile -NoTargetComputer -Message "PoSh-EasyWin Started By: $([System.Security.Principal.WindowsIdentity]::GetCurrent().Name)"
# This prompts the user for accepting the GPLv3 License
if ($AcceptEULA) {
Write-Host "You accepted the EULA." -ForeGroundColor Green
Write-Host "For more infor, visit https://www.gnu.org/licenses/gpl-3.0.html or view a copy in the Dependencies folder.`n" -ForeGroundColor Yellow
}
else {
Get-Content "$Dependencies\GPLv3 Notice.txt" | Out-GridView -Title 'PoSh-EasyWin User Agreement' -PassThru | Set-Variable -Name UserAgreement
if ($UserAgreement) {
Write-LogEntry -LogFile $PewLogFile -NoTargetComputer -Message "PoSh-EasyWin User Agreemennt Accepted By: $([System.Security.Principal.WindowsIdentity]::GetCurrent().Name)"
Write-Host "You accepted the EULA." -ForeGroundColor Green
Write-Host "For more infor, visit https://www.gnu.org/licenses/gpl-3.0.html or view a copy in the Dependencies folder.`n" -ForeGroundColor Yellow
Start-Sleep -Seconds 1
}
else {
[system.media.systemsounds]::Exclamation.play()
Write-LogEntry -LogFile $PewLogFile -NoTargetComputer -Message "PoSh-EasyWin User Agreemennt NOT Accepted By: $([System.Security.Principal.WindowsIdentity]::GetCurrent().Name)"
Write-Host "You must accept the EULA to continue." -ForeGroundColor Red
Write-Host "For more infor, visit https://www.gnu.org/licenses/gpl-3.0.html or view a copy in the Dependencies folder.`n" -ForeGroundColor Yellow
exit
}
Write-LogEntry -LogFile $PewLogFile -NoTargetComputer -Message "===================================================================================================="
}
if (-not (Test-Path "$PewSettings\Form Scaling Modifier.txt")){
Show-FormScaleFrom
if ($script:ResolutionSetOkay) {$null}
else {exit}
$FormScale = $script:ResolutionCheckScalingTrackBar.Value / 10
}
else {
$FormScale = [decimal](Get-Content "$PewSettings\Form Scaling Modifier.txt")
}
if (-not (Test-Path "$PewSettings\User Notice And Acknowledgement.txt")) {
Show-ReadMe
}
# Check for and prompt to install the PSWriteHTML module
if ((Test-Path "$PewSettings\User Notice And Acknowledgement.txt") -and -not (Test-Path "$PewSettings\PSWriteHTML Module Install.txt")) {
if (-not (Get-InstalledModule -Name PSWriteHTML)) {
$InstallPSWriteHTML = [System.Windows.Forms.MessageBox]::Show("PoSh-EasyWin can make use of the PSWriteHTML module to generate dynamic graphs. If this third party module is installed, it provides another means to represent data in an intuitive manner using a web browser. Though this module has been scanned and reviewed, any third party modules may pose a security risk. The PSWriteHTML module files have been packaged with PoSh-EasyWin, but are not being used unless its import. More information can be located at the following:
https://www.powershellgallery.com/packages/PSWriteHTML
https://github.com/EvotecIT/PSWriteHTML
This selection is persistent for this tool, but can be modified within the settings directory. Do you want to import the PSWriteHTML module?","Install PSWriteHTML Module",'YesNo',"Info")
switch ($InstallPSWriteHTML) {
'Yes' {
Write-LogEntry -LogFile $PewLogFile -NoTargetComputer -Message "Opted to import the PSWriteHTML module"
'Import PSWriteHTML: Yes' | Set-Content "$PewSettings\PSWriteHTML Module Install.txt"
}
'No' {
'Import PSWriteHTML: No' | Set-Content "$PewSettings\PSWriteHTML Module Install.txt"
}
}
}
else {
Write-LogEntry -LogFile $PewLogFile -NoTargetComputer -Message "PSWriteHTML was detected as being installed."
'Import PSWriteHTML: Yes' | Set-Content "$PewSettings\PSWriteHTML Module Install.txt"
}
}
if (Test-Path -Path "$Dependencies\Modules\PSWriteHTML"){
if ((Get-Content "$PewSettings\PSWriteHTML Module Install.txt") -match 'Yes') {
Import-Module -Name "$Dependencies\Modules\PSWriteHTML\*\PSWriteHTML.psm1" -Force
}
}
#============================================================================================================================================================
# __ __ _ _____
# | \/ | __ _ (_) _ __ | ___|___ _ __ _ __ ___
# | |\/| | / _` || || '_ \ | |_ / _ \ | '__|| '_ ` _ \
# | | | || (_| || || | | | | _|| (_) || | | | | | | |
# |_| |_| \__,_||_||_| |_| |_| \___/ |_| |_| |_| |_|
#
#============================================================================================================================================================
#Start Progress bar form loading
$global:ScriptBlockForGuiLoadAndProgressBar = {
Update-FormProgress "$Dependencies\Code\Main\Import-FunctionsForMain.ps1"
. "$Dependencies\Code\Main\Import-FunctionsForMain.ps1"
Update-FormProgress "$Dependencies\Code\Main\Import-FunctionsForCredentialManagement.ps1"
. "$Dependencies\Code\Main\Import-FunctionsForCredentialManagement.ps1"
Update-FormProgress "$Dependencies\Code\Main\Import-FunctionsForImportData.ps1"
. "$Dependencies\Code\Main\Import-FunctionsForImportData.ps1"
Update-FormProgress "$Dependencies\Code\Main\Import-FunctionsForTreeView.ps1"
. "$Dependencies\Code\Main\Import-FunctionsForTreeView.ps1"
Update-FormProgress "$Dependencies\Code\Main\Import-FunctionsForEnumeration.ps1"
. "$Dependencies\Code\Main\Import-FunctionsForEnumeration.ps1"
Start-Process -FilePath powershell.exe -ArgumentList "-WindowStyle Hidden -Command Invoke-Command {${function:Show-SystemTrayNotifyIcon}} -ArgumentList @('$PewCollectedData','$CommandsAndScripts','$CommandsEndpoint','$CommandsActiveDirectory',$PewScriptProcessId,[bool]'`$$FormAdminCheck','$EasyWinIcon','$Font',$($PewScript.trim('&')),'$InitialScriptLoadTime')" -PassThru `
| Select-Object -ExpandProperty Id `
| Set-Variable FormHelperProcessId
# The Show-ProgressBar.ps1 is topmost upon loading to ensure it's displayed intially, but is then able to be move unpon
$ResolutionCheckForm.topmost = $false
$PoShEasyWinAccountLaunch = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
$PoShEasyWin = New-Object System.Windows.Forms.Form -Property @{
Text = "PoSh-EasyWin ($PoShEasyWinAccountLaunch) [$InitialScriptLoadTime]"
Icon = [System.Drawing.Icon]::ExtractAssociatedIcon("$EasyWinIcon")
Width = $FormScale * $FormOriginalWidth
Height = $FormScale * $FormOriginalHeight
TopMost = $true
AutoScroll = $false
ControlBox = $true
MaximizeBox = $false
MinimizeBox = $true
StartPosition = "CenterScreen"
FormBorderStyle = 'Sizable' # Fixed3D, FixedDialog, FixedSingle, FixedToolWindow, None, Sizable, SizableToolWindow
Add_Load = {
$This.TopMost = $false
if ((Test-Path "$PewSettings\Use Selected Credentials.txt")) {
$SelectedCredentialName = Get-Content "$PewSettings\Use Selected Credentials.txt"
$script:SelectedCredentialPath = Get-ChildItem "$CredentialManagementPath\$SelectedCredentialName"
$script:Credential = Import-CliXml $script:SelectedCredentialPath
$StatusListBox.Items.Clear()
$StatusListBox.Items.Add("Credentials: $SelectedCredentialName")
$script:ComputerListProvideCredentialsCheckBox.checked = $true
}
else {
$StatusListBox.Items.Clear()
$StatusListBox.Items.Add("Credentials: $([System.Security.Principal.WindowsIdentity]::GetCurrent().Name)")
}
}
Add_Closing = {
param($sender,$Selection)
$script:VerifyCloseForm = New-Object System.Windows.Forms.Form -Property @{
Text = "Close"
Width = $FormScale * 250
Height = $FormScale * 109
TopMost = $true
Icon = [System.Drawing.Icon]::ExtractAssociatedIcon("$EasyWinIcon")
Font = New-Object System.Drawing.Font("$Font",($FormScale * 11),0,0,0)
FormBorderStyle = 'Fixed3d'
StartPosition = 'CenterScreen'
showintaskbar = $true
ControlBox = $true
MaximizeBox = $false
MinimizeBox = $false
Add_Closing = {
if ($script:VerifyToCloseForm -eq $true) { $Selection.Cancel = $false }
elseif ($script:VerifyToCloseForm -eq $false){ $Selection.Cancel = $true }
else { $Selection.Cancel = $true }
$this.TopMost = $false
$this.dispose()
$this.close()
}
}
$VerifyCloseLabel = New-Object System.Windows.Forms.Label -Property @{
Text = 'Do you want to close PoSh-EasyWin?'
Width = $FormScale * 250
Height = $FormScale * 22
Left = $FormScale * 10
Top = $FormScale * 10
}
$script:VerifyCloseForm.Controls.Add($VerifyCloseLabel)
$VerifyYesButton = New-Object System.Windows.Forms.Button -Property @{
Text = 'Yes'
Width = $FormScale * 100
Height = $FormScale * 22
Left = $FormScale * 10
Top = $VerifyCloseLabel.Top + $VerifyCloseLabel.Height
BackColor = 'LightGray'
Add_Click = {
$script:VerifyToCloseForm = $True
Stop-Process -id $FormHelperProcessId -Force -ErrorAction SilentlyContinue
$script:VerifyCloseForm.close()
}
}
$script:VerifyCloseForm.Controls.Add($VerifyYesButton)
$VerifyNoButton = New-Object System.Windows.Forms.Button -Property @{
Text = 'No'
Width = $FormScale * 100
Height = $FormScale * 22
Left = $VerifyYesButton.Left + $VerifyYesButton.Width + ($FormScale * 10)
Top = $VerifyYesButton.Top
BackColor = 'LightGray'
Add_Click = {
$script:VerifyToCloseForm = $false
$script:VerifyCloseForm.close()
}
}
$script:VerifyCloseForm.Controls.Add($VerifyNoButton)
$script:VerifyCloseForm.ShowDialog()
}
}
$TopLeftPanel = New-Object System.Windows.Forms.Panel -Property @{
Left = $FormScale * 5
Top = $FormScale * 5
Width = $FormScale * 460
Height = $FormScale * 45
BorderStyle = 'FixedSingle'
}
$PoShEasyWin.Controls.Add($TopLeftPanel)
$PoShEasyWinLogoPictureBox = New-Object Windows.Forms.PictureBox -Property @{
Text = "PoSh-EasyWin Image"
Left = $FormScale * 5
Top = $FormScale * 5
Width = $FormScale * 285
Height = $FormScale * 35
Image = [System.Drawing.Image]::Fromfile("$Dependencies\Images\PoSh-EasyWin Image 01.png")
SizeMode = 'StretchImage'
}
$TopLeftPanel.Controls.Add($PoShEasyWinLogoPictureBox)
$QueryAndCollectionPanel = New-Object System.Windows.Forms.Panel -Property @{
Left = $FormScale * 5
Top = $TopLeftPanel.Top + $TopLeftPanel.Height
Width = $FormScale * 460
Height = $FormScale * 590
BorderStyle = 'FixedSingle'
}
$MainLeftTabControlImageList = New-Object System.Windows.Forms.ImageList -Property @{
ImageSize = @{
Width = $FormScale * 16
Height = $FormScale * 16
}
}
# Index 0 = Commands
$MainLeftTabControlImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\PowerShell.png"))
# Index 1 = Search
$MainLeftTabControlImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\Search.png"))
# Index 2 = Interaction
$MainLeftTabControlImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\Interaction.png"))
# Index 3 = Enumeration / Scanning
$MainLeftTabControlImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\Radar-Scanning.png"))
# Index 4 = OpNotes
$MainLeftTabControlImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\Notes.png"))
# Index 5 = Info
$MainLeftTabControlImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\Info.png"))
$MainLeftTabControl = New-Object System.Windows.Forms.TabControl -Property @{
Left = 0
Width = $FormScale * 460
Height = $FormScale * 590
Font = New-Object System.Drawing.Font("$Font",$($FormScale * 10),1,2,1)
ForeColor = "Blue"
ImageList = $MainLeftTabControlImageList
Appearance = [System.Windows.Forms.TabAppearance]::Buttons
Hottrack = $true
}
$QueryAndCollectionPanel.Controls.Add($MainLeftTabControl)
# This tab contains all the individual commands within the command treeview, such as the PowerShell, WMI, and Native Commands using the WinRM, RPC/DCOM, and SMB protocols
Update-FormProgress "$Dependencies\Code\Main\Tabs\Commands.ps1"
. "$Dependencies\Code\Main\Tabs\Commands.ps1"
Update-FormProgress "$Dependencies\Code\Main\Tabs\Search.ps1"
. "$Dependencies\Code\Main\Tabs\Search.ps1"
Update-FormProgress "$Dependencies\Code\Main\Tabs\Interactions.ps1"
. "$Dependencies\Code\Main\Tabs\Interactions.ps1"
Update-FormProgress "$Dependencies\Code\Main\Tabs\Enumeration.ps1"
. "$Dependencies\Code\Main\Tabs\Enumeration.ps1"
Update-FormProgress "$Dependencies\Code\Main\Tabs\Checklists.ps1"
. "$Dependencies\Code\Main\Tabs\Checklists.ps1"
Update-FormProgress "$Dependencies\Code\Main\Tabs\OpNotes.ps1"
. "$Dependencies\Code\Main\Tabs\OpNotes.ps1"
Update-FormProgress "$Dependencies\Code\Main\Tabs\Info.ps1"
. "$Dependencies\Code\Main\Tabs\Info.ps1"
$PoShEasyWin.Controls.Add($QueryAndCollectionPanel)
$ComputerAndAccountTreeNodeViewPanel = New-Object System.Windows.Forms.Panel -Property @{
Left = $QueryAndCollectionPanel.Left + $QueryAndCollectionPanel.Width
Top = $FormScale * 5
Width = $FormScale * 200
Height = $FormScale * 635
BorderStyle = 'FixedSingle'
}
Update-FormProgress "$Dependencies\Code\Main\Context Menu Strip\Display-ContextMenuForAccountsTreeNode.ps1"
. "$Dependencies\Code\Main\Context Menu Strip\Display-ContextMenuForAccountsTreeNode.ps1"
Display-ContextMenuForAccountsTreeNode -ClickedOnArea
$ComputerAndAccountTreeViewTabControlImageList = New-Object System.Windows.Forms.ImageList -Property @{
ImageSize = @{
Width = $FormScale * 16
Height = $FormScale * 16
}
}
# Index 0 = Endpoints
$ComputerAndAccountTreeViewTabControlImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\Endpoint-Default.png"))
# Index 1 = Accounts
$ComputerAndAccountTreeViewTabControlImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\Accounts.png"))
$ComputerAndAccountTreeViewTabControl = New-Object System.Windows.Forms.TabControl -Property @{
Left = 0
Top = 0
Width = $FormScale * 192
Height = $FormScale * 635
Appearance = [System.Windows.Forms.TabAppearance]::Buttons
Hottrack = $true
Dock = 'Fill'
Font = New-Object System.Drawing.Font("$Font",$($FormScale * 10),1,2,1)
Add_Click = {
if ($This.SelectedTab -eq $ComputerTreeviewTab) { $InformationTabControl.SelectedTab = $Section3HostDataTab }
elseif ($This.SelectedTab -eq $AccountsTreeviewTab) { $InformationTabControl.SelectedTab = $Section3AccountDataTab }
}
ImageList = $ComputerAndAccountTreeViewTabControlImageList
}
$ComputerAndAccountTreeNodeViewPanel.Controls.Add($ComputerAndAccountTreeViewTabControl)
# Populate Auto Tag List used for Host Data tagging and Searching
$TagListFileContents = Get-Content -Path $TagAutoListFile
$ComputerTreeviewTab = New-Object System.Windows.Forms.TabPage -Property @{
Text = "Endpoints "
Font = New-Object System.Drawing.Font("$Font",$($FormScale * 11),0,0,0)
UseVisualStyleBackColor = $True
ImageIndex = 0
}
$ComputerAndAccountTreeViewTabControl.Controls.Add($ComputerTreeviewTab)
$script:UpdateComputerTreeViewScriptBlock = {
# This variable stores data on checked checkboxes, so boxes checked remain among different views
$script:ComputerTreeViewSelected = @()
[System.Windows.Forms.TreeNodeCollection]$AllTreeViewNodes = $script:ComputerTreeView.Nodes
foreach ($root in $AllTreeViewNodes) {
foreach ($Category in $root.Nodes) {
foreach ($Entry in $Category.nodes) {
if ($Entry.Checked) {
$script:ComputerTreeViewSelected += $Entry.Text
}
}
}
}
$script:ComputerTreeView.Nodes.Clear()
Initialize-TreeViewData -Endpoint
Normalize-TreeViewData -Endpoint
Save-TreeViewData -Endpoint
$script:ComputerTreeView.Nodes.Add($script:TreeNodeComputerList)
Foreach($Computer in $script:ComputerTreeViewData) {
Add-TreeViewData -Endpoint -RootNode $script:TreeNodeComputerList -Category $Computer.$($This.SelectedItem) -Entry $Computer.Name -ToolTip $Computer.IPv4Address -Metadata $Computer
}
Update-TreeViewState -Endpoint
Update-TreeViewData -Endpoint -TreeView $script:ComputerTreeView.Nodes
}
$script:ComputerTreeNodeComboBox = New-Object System.Windows.Forms.ComboBox -Property @{
Text = 'CanonicalName'
Left = 0
Top = $FormScale * 5
Width = $FormScale * 135
Height = $FormScale * 25
Font = New-Object System.Drawing.Font("$Font",$($FormScale * 11),0,0,0)
AutoCompleteSource = "ListItems"
AutoCompleteMode = "SuggestAppend"
add_SelectedIndexChanged = $script:UpdateComputerTreeViewScriptBlock
}
$ComputerTreeNodeComboBoxList = @('CanonicalName', 'OperatingSystem', 'OperatingSystemHotfix', 'OperatingSystemServicePack', 'Enabled', 'LockedOut', 'LogonCount', 'Created', 'Modified', 'LastLogonDate', 'MemberOf', 'isCriticalSystemObject', 'HomedirRequired', 'Location', 'ProtectedFromAccidentalDeletion', 'TrustedForDelegation')
ForEach ($Item in $ComputerTreeNodeComboBoxList) { $script:ComputerTreeNodeComboBox.Items.Add($Item) }
$ComputerTreeviewTab.Controls.Add($script:ComputerTreeNodeComboBox)
$ComputerTreeNodeSearchGreedyCheckbox = New-Object System.Windows.Forms.CheckBox -Property @{
Text = "Greedy"
Left = $script:ComputerTreeNodeComboBox.Left + $script:ComputerTreeNodeComboBox.Width + $($FormScale * 5)
Top = $script:ComputerTreeNodeComboBox.Top - ($FormScale * 6)
Height = $FormScale * 25
Width = $FormScale * 65
Checked = $true
Font = New-Object System.Drawing.Font("$Font",$($FormScale * 11),0,0,0)
}
$ComputerTreeviewTab.Controls.Add($ComputerTreeNodeSearchGreedyCheckbox)
# Initial load of CSV data
$script:ComputerTreeViewData = $null
if (Test-Path $EndpointTreeNodeFileSave) {
$script:ComputerTreeViewData = Import-Csv $EndpointTreeNodeFileSave
}
else {
$script:ComputerTreeViewData = Import-Csv $EndpointTreeNodeFileSaveDemo
}
$script:ComputerTreeViewSelected = ""
$ComputerTreeNodeSearchComboBox = New-Object System.Windows.Forms.ComboBox -Property @{
Name = "Search TextBox"
Left = $script:ComputerTreeNodeComboBox.Left
Top = $script:ComputerTreeNodeComboBox.Top + $script:ComputerTreeNodeComboBox.Height + ($FormScale * 5)
Width = $FormScale * 135
Height = $FormScale * 25
AutoCompleteSource = "ListItems"
AutoCompleteMode = "SuggestAppend"
Font = New-Object System.Drawing.Font("$Font",$($FormScale * 11),0,0,0)
Add_KeyDown = { if ($_.KeyCode -eq "Enter") { Search-TreeViewData -Endpoint } }
Add_MouseHover = {
Show-ToolTip -Title "Search for Hosts" -Icon "Info" -Message @"
+ Searches through host data and returns results as nodes.
+ Search can include any character.
+ Tags are pre-built to assist with standarized notes.
+ Can search CSV Results, enable them in the Options Tab.
"@
}
}
ForEach ($Tag in $TagListFileContents) { [void] $ComputerTreeNodeSearchComboBox.Items.Add($Tag) }
$ComputerTreeviewTab.Controls.Add($ComputerTreeNodeSearchComboBox)
$ComputerTreeNodeSearchButton = New-Object System.Windows.Forms.Button -Property @{
Text = "Search"
Left = $ComputerTreeNodeSearchComboBox.Left + $ComputerTreeNodeSearchComboBox.Width + ($FormScale * 5)
Top = $ComputerTreeNodeSearchComboBox.Top
Width = $FormScale * 55
Height = $FormScale * 22
Add_Click = {
Search-TreeViewData -Endpoint
}
Add_MouseHover = {
Show-ToolTip -Title "Search for Hosts" -Icon "Info" -Message @"
+ Searches through host data and returns results as nodes.
+ Search can include any character.
+ Tags are pre-built to assist with standarized notes.
+ Can search CSV Results, enable them in the Options Tab.
"@
}
}
$ComputerTreeviewTab.Controls.Add($ComputerTreeNodeSearchButton)
Add-CommonButtonSettings -Button $ComputerTreeNodeSearchButton
Remove-TreeViewEmptyCategory -Endpoint
Update-FormProgress "$Dependencies\Code\Main\Context Menu Strip\Display-ContextMenuForComputerTreeNode.ps1"
. "$Dependencies\Code\Main\Context Menu Strip\Display-ContextMenuForComputerTreeNode.ps1"
Display-ContextMenuForComputerTreeNode -ClickedOnArea
# The .ImageList allows for the images to be loaded from disk to memory only once, then referenced using their index number
$ComputerTreeviewImageList = New-Object System.Windows.Forms.ImageList -Property @{
ImageSize = @{
Width = $FormScale * 16
Height = $FormScale * 16
}
}
$script:ComputerTreeViewIconList = Get-ChildItem "$Dependencies\Images\Icons\Endpoint"
# This hashtable is used to maintain a relationship between the imageindex number and the image filepath, it is used when populating the Endpoint Data tab
$EndpointTreeviewImageHashTable = [ordered]@{}
# Position 0 = Default Image, this one is often seen when clicking on a treenode
$ComputerTreeviewImageList.Images.Add([System.Drawing.Image]::FromFile("$EasyWinIcon"))
$EndpointTreeviewImageHashTable['0'] = "$EasyWinIcon"
# Position 1 = used as the default image that is loaded against the .treeview itself, thus shown at the top level for the Organizational Units, It gets overwritten by each node that is added
$ComputerTreeviewImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\Icon OU LightYellow.png"))
$EndpointTreeviewImageHashTable['1'] = "$Dependencies\Images\Icons\Icon OU LightYellow.png"
# Position 2 = used as the default image for the computer/account/entry node. Normalize-TreeViewData.ps1 populates it by default if an imageindex number doesn't exist for it already
$ComputerTreeviewImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\Endpoint-Default.png"))
$EndpointTreeviewImageHashTable['2'] = "$Dependencies\Images\Icons\Endpoint-Default.png"
# The .ImageList allows for the images to be loaded from disk to memory only once, then referenced using their index number
$ComputerTreeviewImageList = New-Object System.Windows.Forms.ImageList -Property @{
ImageSize = @{
Width = $FormScale * 16
Height = $FormScale * 16
}
}
$script:ComputerTreeViewIconList = Get-ChildItem "$Dependencies\Images\Icons\Endpoint"
# This hashtable is used to maintain a relationship between the imageindex number and the image filepath, it is used when populating the Endpoint Data tab
$EndpointTreeviewImageHashTable = [ordered]@{}
# Position 0 = Default Image, this one is often seen when clicking on a treenode
$ComputerTreeviewImageList.Images.Add([System.Drawing.Image]::FromFile("$EasyWinIcon"))
$EndpointTreeviewImageHashTable['0'] = "$EasyWinIcon"
# Position 1 = used as the default image that is loaded against the .treeview itself, thus shown at the top level for the Organizational Units, It gets overwritten by each node that is added
$ComputerTreeviewImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\OU-Default.png"))
$EndpointTreeviewImageHashTable['1'] = "$Dependencies\Images\Icons\OU-Default.png"
# Position 2 = PowerShell Icon, used to indicate an active powershell session
$ComputerTreeviewImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\PowerShell.png"))
$EndpointTreeviewImageHashTable['2'] = "$Dependencies\Images\Icons\PowerShell.png"
# Position 3 = used as the default image for the computer/account/entry node. Normalize-TreeViewData.ps1 populates it by default if an imageindex number doesn't exist for it already
$ComputerTreeviewImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\Endpoint-Default.png"))
$EndpointTreeviewImageHashTable['3'] = "$Dependencies\Images\Icons\Endpoint-Default.png"
# Position 4 = Windows Server Default
$ComputerTreeviewImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\Windows-Server-Default.png"))
$EndpointTreeviewImageHashTable['4'] = "$Dependencies\Images\Icons\Windows-Server-Default.png"
# Position 5 = Windows Desktop Client Default
$ComputerTreeviewImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\Endpoint\Windows-Desktop-Client.png"))
$EndpointTreeviewImageHashTable['5'] = "$Dependencies\Images\Icons\Endpoint\Windows-Desktop-Client.png"
# Position 6 = Windows Desktop `95
$ComputerTreeviewImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\Endpoint\Windows-Desktop-95.png"))
$EndpointTreeviewImageHashTable['6'] = "$Dependencies\Images\Icons\Endpoint\Windows-Desktop-95.png"
# Position 7 = Windows Desktop XP
$ComputerTreeviewImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\Endpoint\Windows-Desktop-XP.png"))
$EndpointTreeviewImageHashTable['7'] = "$Dependencies\Images\Icons\Endpoint\Windows-Desktop-XP.png"
# Position 8 = Windows Desktop Vista
$ComputerTreeviewImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\Endpoint\Windows-Desktop-Vista.png"))
$EndpointTreeviewImageHashTable['8'] = "$Dependencies\Images\Icons\Endpoint\Windows-Desktop-Vista.png"
# Position 9 = Windows Desktop 7
$ComputerTreeviewImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\Endpoint\Windows-Desktop-7.png"))
$EndpointTreeviewImageHashTable['9'] = "$Dependencies\Images\Icons\Endpoint\Windows-Desktop-7.png"
# Position 10 = Windows Desktop 8
$ComputerTreeviewImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\Endpoint\Windows-Desktop-8.png"))
$EndpointTreeviewImageHashTable['10'] = "$Dependencies\Images\Icons\Endpoint\Windows-Desktop-8.png"
# Position 11 = Windows Desktop 10
$ComputerTreeviewImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\Endpoint\Windows-Desktop-10.png"))
$EndpointTreeviewImageHashTable['11'] = "$Dependencies\Images\Icons\Endpoint\Windows-Desktop-10.png"
# Position 12 = Windows Desktop 11
$ComputerTreeviewImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\Endpoint\Windows-Desktop-11.png"))
$EndpointTreeviewImageHashTable['12'] = "$Dependencies\Images\Icons\Endpoint\Windows-Desktop-11.png"
# Position 13 = Linux Ubuntu
$ComputerTreeviewImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\Endpoint\Linux-OS-Ubuntu.png"))
$EndpointTreeviewImageHashTable['13'] = "$Dependencies\Images\Icons\Endpoint\Linux-OS-Ubuntu.png"
# Position 14 = Linux Debian
$ComputerTreeviewImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\Endpoint\Linux-OS-Debian.png"))
$EndpointTreeviewImageHashTable['14'] = "$Dependencies\Images\Icons\Endpoint\Linux-OS-Debian.png"
# Position 15 = Linux Red Hat
$ComputerTreeviewImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\Endpoint\Linux-OS-Red-Hat.png"))
$EndpointTreeviewImageHashTable['15'] = "$Dependencies\Images\Icons\Endpoint\Linux-OS-Red-Hat.png"
# Position 16 = Linux CentOS
$ComputerTreeviewImageList.Images.Add([System.Drawing.Image]::FromFile("$Dependencies\Images\Icons\Endpoint\Linux-OS-CentOS.png"))
$EndpointTreeviewImageHashTable['16'] = "$Dependencies\Images\Icons\Endpoint\Linux-OS-CentOS.png"
# note, if you update this variable, update this one too... $ComputerTreeViewChangeIconRootTreeNodeCount
$script:EndpointTreeviewImageHashTableCount = 16
foreach ($Image in $script:ComputerTreeViewIconList.FullName) {
$script:EndpointTreeviewImageHashTableCount++
$ComputerTreeviewImageList.Images.Add([System.Drawing.Image]::FromFile("$Image"))
$EndpointTreeviewImageHashTable["$script:EndpointTreeviewImageHashTableCount"] = "$Image"
}
# Position -1 = currently unused
$ComputerTreeviewImageList.Images.Add([System.Drawing.Image]::FromFile("$high101bro_image"))
$script:EndpointTreeviewImageHashTableCount++
$EndpointTreeviewImageHashTable["$script:EndpointTreeviewImageHashTableCount"] = "$Dependencies\Images\high101bro Logo Color Transparent.png"
$script:ComputerTreeView = New-Object System.Windows.Forms.TreeView -Property @{
Left = $ComputerTreeNodeSearchComboBox.Left
Top = $ComputerTreeNodeSearchButton.Top + $ComputerTreeNodeSearchButton.Height + ($FormScale * 5)
Width = $FormScale * 195
Height = $FormScale * 555
# Note: size and location properties are are managed by
Font = New-Object System.Drawing.Font("$Font",$($FormScale * 11),0,0,0)
CheckBoxes = $True
#LabelEdit = $True #Not implementing yet...
ShowLines = $True
ShowNodeToolTips = $True
Add_Click = {
Update-TreeViewData -Endpoint -TreeView $this.Nodes
# When the node is checked, it updates various items
[System.Windows.Forms.TreeNodeCollection]$AllTreeViewNodes = $this.Nodes
foreach ($root in $AllTreeViewNodes) {
if ($root.checked) {
$root.Expand()
foreach ($Category in $root.Nodes) {
$Category.Expand()
foreach ($Entry in $Category.nodes) {
$Entry.Checked = $True
$Entry.NodeFont = New-Object System.Drawing.Font("$Font",$($FormScale * 10),1,1,1)
$Entry.ForeColor = [System.Drawing.Color]::FromArgb(0,0,0,224)
$Category.NodeFont = New-Object System.Drawing.Font("$Font",$($FormScale * 10),1,1,1)
$Category.ForeColor = [System.Drawing.Color]::FromArgb(0,0,0,224)
$Root.NodeFont = New-Object System.Drawing.Font("$Font",$($FormScale * 10),1,1,1)
$Root.ForeColor = [System.Drawing.Color]::FromArgb(0,0,0,224)
}
}
}
foreach ($Category in $root.Nodes) {
$EntryNodeCheckedCount = 0
if ($Category.checked) {
$Category.Expand()
$Category.NodeFont = New-Object System.Drawing.Font("$Font",$($FormScale * 10),1,1,1)
$Category.ForeColor = [System.Drawing.Color]::FromArgb(0,0,0,224)
$Root.NodeFont = New-Object System.Drawing.Font("$Font",$($FormScale * 10),1,1,1)
$Root.ForeColor = [System.Drawing.Color]::FromArgb(0,0,0,224)
foreach ($Entry in $Category.nodes) {
$EntryNodeCheckedCount += 1
$Entry.Checked = $True
$Entry.NodeFont = New-Object System.Drawing.Font("$Font",$($FormScale * 10),1,1,1)
$Entry.ForeColor = [System.Drawing.Color]::FromArgb(0,0,0,224)
}
}
if (!($Category.checked)) {
foreach ($Entry in $Category.nodes) {
#if ($Entry.isselected) {
if ($Entry.checked) {
$EntryNodeCheckedCount += 1
$Entry.NodeFont = New-Object System.Drawing.Font("$Font",$($FormScale * 10),1,1,1)
$Entry.ForeColor = [System.Drawing.Color]::FromArgb(0,0,0,224)
$Root.NodeFont = New-Object System.Drawing.Font("$Font",$($FormScale * 10),1,1,1)
$Root.ForeColor = [System.Drawing.Color]::FromArgb(0,0,0,224)
}
elseif (!($Entry.checked)) {
if ($CategoryCheck -eq $False) {$Category.Checked = $False}
$Entry.NodeFont = New-Object System.Drawing.Font("$Font",$($FormScale * 10),1,1,1)
$Entry.ForeColor = [System.Drawing.Color]::FromArgb(0,0,0,0)
}
}
}
if ($EntryNodeCheckedCount -gt 0) {
$Category.NodeFont = New-Object System.Drawing.Font("$Font",$($FormScale * 10),1,1,1)
$Category.ForeColor = [System.Drawing.Color]::FromArgb(0,0,0,224)
$Root.NodeFont = New-Object System.Drawing.Font("$Font",$($FormScale * 10),1,1,1)
$Root.ForeColor = [System.Drawing.Color]::FromArgb(0,0,0,224)
}
else {
$Category.NodeFont = New-Object System.Drawing.Font("$Font",$($FormScale * 10),1,1,1)
$Category.ForeColor = [System.Drawing.Color]::FromArgb(0,0,0,0)
$Root.NodeFont = New-Object System.Drawing.Font("$Font",$($FormScale * 10),1,1,1)
$Root.ForeColor = [System.Drawing.Color]::FromArgb(0,0,0,0)
}
}
}
}
Add_AfterSelect = {
Update-TreeViewData -Endpoint -TreeView $this.Nodes
# This will return data on hosts selected/highlight, but not necessarily checked
[System.Windows.Forms.TreeNodeCollection]$AllTreeViewNodes = $this.Nodes
foreach ($root in $AllTreeViewNodes) {
if ($root.isselected) {
$script:ComputerTreeViewSelected = ""
$StatusListBox.Items.clear()
$StatusListBox.Items.Add("Category: $($root.Text)")
#Removed For Testing#$ResultsListBox.Items.Clear()
#$ResultsListBox.Items.Add("- Checkbox this Category to query all its hosts")
$script:Section3HostDataNameTextBox.Text = 'N/A'
$Section3HostDataOUTextBox.Text = 'N/A'
$Section3EndpointDataCreatedTextBox.Text = 'N/A'