-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInstall-Software.ps1
More file actions
1268 lines (1175 loc) · 52.5 KB
/
Install-Software.ps1
File metadata and controls
1268 lines (1175 loc) · 52.5 KB
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
Install all the software and configuration usually needed for a computer.
.PARAMETER Elevated
This parameter is for internal use to check whether an UAC prompt has already been attempted.
#>
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "Elevated", Justification="Used in utils")]
param(
[switch]$Elevated
)
#####
# Script startup
#####
. "${PSScriptRoot}\Utils.ps1"
if ($RepoInUserDir) {
Update-Repo
}
# This should be as early as possible to avoid loading the function definitions etc. twice.
Elevate($myinvocation.MyCommand.Definition)
Start-Transcript -Path "${LogPath}\install-software_$(Get-Date -Format "yyyy-MM-dd_HH-mm").txt"
if (! $RepoInUserDir) {
Update-Repo
}
# Startup info
$host.ui.RawUI.WindowTitle = "Mika's computer installation script"
Show-Output -ForegroundColor Cyan "Starting Mika's computer installation script."
Show-Output -ForegroundColor Cyan `
"If some installer requests a reboot, select no, and only reboot the computer when the installation script is ready."
Request-DomainConnection
Show-Output -ForegroundColor Cyan `
"The graphical user interface (GUI) is a very preliminary version and will be improved in the future."
Show-Output -ForegroundColor Cyan `
"If it doesn't fit on your monitor, please reduce the display scaling at:"
Show-Output -ForegroundColor Cyan `
"`"Settings -> System -> Display -> Scale and layout -> Change the size of text, apps and other items`""
# Startup tasks
Add-ScriptShortcuts
Set-RepoPermissions
Test-PendingRebootAndExit
if ($env:ComputerName -eq "agx-z2e-win") {
Install-Module DisplayConfig
}
# Global variables
$GlobalHeight = 800;
$GlobalWidth = 700;
$SoftwareRepoPath = "V:\IT\Software"
$ComputerSystem = Get-CimInstance -ClassName Win32_ComputerSystem
#####
# Installer definitions
#####
# TODO: hide non-work-related apps on domain computers
$ChocoPrograms = [ordered]@{
"7-Zip" = "7zip", "File compression utility";
"ActivityWatch" = "activitywatch", "Time management utility";
"Adobe Acrobat Reader DC" = "adobereader", "PDF reader. Not usually needed, as web browsers have good integrated pdf readers.";
"AltSnap" = "altsnap", "For moving windows easily";
"Anaconda 3 (NOTE!)" = "anaconda3", "NOTE! Comes with lots of libraries. Use Miniconda or regular Python instead, unless you absolutely need this. Installation with Chocolatey does not work with PyCharm without custom symlinks.";
"Android Debug Bridge" = "adb", "For developing Android applications";
"BleachBit" = "bleachbit", "Utility for freeing disk space";
"BOINC" = "boinc", "Distributed computing platform";
"Chocolatey GUI (RECOMMENDED!)" = "chocolateygui", "Graphical user interface for managing packages installed with this script and for installing additional software.";
"CLion" = "clion-ide", "C/C++ IDE, commercial use requires a license";
"CMake" = "cmake", "C/C++ make utility";
"Discord" = "discord", "Chat and group call platform";
"DisplayCal" = "displaycal", "Display calibration utility";
"Docker Desktop (NOTE!)" = "docker-desktop", "Container platform. NOTE! Windows Subsystem for Linux 2 (WSL 2) has to be installed before installing this";
"EA App" = "ea-app", "Game store";
"eDrawings Viewer" = "edrawings-viewer", "2D & 3D CAD viewer";
"Epic Games Launcher" = "epicgameslauncher", "Game store";
"Firefox" = "firefox", "Web browser";
"GIMP" = "gimp", "Image editor";
# "Git" = "git", "Version control";
"GNU Octave" = "octave", "Free MATLAB alternative";
"Google Drive" = "googledrive", "Cloud storage client";
"Gpg4Win" = "gpg4win", "GPG / PGP software for encryption and signing";
"HWiNFO" = "hwinfo.install", "System monitoring utility";
"ImageJ" = "imagej", "Image processing and analysis software";
"Inkscape" = "inkscape", "Vector graphics editor";
"Intel Driver & Support Assistant" = "intel-dsa", "Intel driver updater";
"Java Runtime (JRE) 8" = "javaruntime", "Required for running Java-based applications";
"Jellyfin" = "jellyfin-media-player", "Jellyfin client for playing media from a self-hosted server";
"KeePassXC" = "keepassxc", "Password manager";
"KLayout" = "klayout", "Lithography mask editor";
"Kingston SSD Manager" = "kingston-ssd-manager", "Management tool and firmware updater for Kingston SSDs";
"LibreOffice" = "libreoffice-fresh", "Office suite";
"Logi Options+" = "logioptionsplus", "Driver for logitech input devices";
"Logitech Gaming Software" = "logitechgaming", "Driver for old Logitech gaming input devices";
"Logitech G Hub" = "lghub", "Driver for new Logitech gaming input devices";
"Mattermost" = "mattermost-desktop", "Messaging app for teams and organizations (open source Slack alternative)";
"Microsoft Teams" = "microsoft-teams", "Instant messaging and video conferencing platform";
"MiKTeX" = "miktex", "LaTeX environment";
# Minecraft should be installed from the Microsoft Store to enable automatic updates.
# "Minecraft" = "minecraft-launcher", "The classic sandbox game";
"Miniconda 3 (NOTE!)" = "miniconda3", "Anaconda package manager and Python 3 without the pre-installed libraries. NOTE! Installation with Chocolatey does not work with PyCharm without custom symlinks.";
"mRemoteNG" = "mremoteng", "Remote connections manager (RDP, VNC, SSH etc.)";
"Mumble" = "mumble", "Group call platform";
"Notepad++" = "notepadplusplus", "Text editor";
"NVIDIA App" = "nvidia-app", "NVIDIA GPU driver utility";
"NVM" = "nvm", "Node.js Version Manager";
"Obsidian" = "obsidian", "A note-taking app";
"OBS Studio" = "obs-studio", "Screen capture and broadcasting utility";
"OpenVPN" = "openvpn", "VPN client";
"PDFsam" = "pdfsam", "PDF Split & Merge utility";
"PDF-XChange Editor" = "pdfxchangeeditor", "PDF editor";
"PDF Arranger" = "pdfarranger", "PDF split & merge utility";
"pgAdmin" = "pgadmin4", "Graphical user interface (GUI) for managing PostgreSQL";
"Plex" = "plex", "Plex client for playing media from a self-hosted server";
"Plexamp" = "plexamp", "Plex client for playing music from a self-hosted server";
"PostgreSQL" = "postgresql", "Database for e.g. web app development";
"PowerToys" = "powertoys", "Various utilities for Windows";
"PuTTY" = "putty", "SSH, Telnet and serial port terminal client";
"PyCharm Community" = "pycharm-community", "Python IDE";
"PyCharm Professional" = "pycharm", "Professional Python IDE, requires a license";
"Python (NOTE!)" = "python", "NOTE! This will be updated automatically in the future, which may break installed libraries and virtualenvs.";
"qBittorrent" = "qbittorrent", "Torrent client";
"Raspberry Pi Imager" = "rpi-imager", "A tool for formatting SD cards for Raspberry Pi";
"RescueTime" = "rescuetime", "Time management utility, requires a license";
"Rufus" = "rufus", "Creates USB installers for operating systems";
"RustRover" = "rustrover", "Rust IDE, commercial use requires a license";
"Samsung Magician" = "samsung-magician", "Samsung SSD management software";
"Signal" = "signal", "Secure instant messenger";
"Slack" = "slack", "Messaging app for teams and organizations";
"SpaceSniffer" = "spacesniffer", "See what's consuming the hard disk space";
"Speedtest CLI" = "speedtest", "Command-line utility for measuring internet speed";
"Spotify" = "spotify", "Music streaming service client";
"Steam" = "steam", "Game store";
"Stream Deck" = "streamdeck", "Control software for Elgato Stream Decks";
"Syncthing / SyncTrayzor" = "synctrayzor", "Utility for directly synchronizing files between devices";
"TeamViewer" = "teamviewer", "Remote control utility, commercial use requires a license";
"Telegram" = "telegram", "Instant messenger";
"Texmaker" = "texmaker", "LaTeX editor";
"Thunderbird" = "thunderbird", "Email client";
"Tidal" = "tidal", "Music streaming service client";
"TightVNC" = "tightvnc", "VNC server. Can be used with noVNC by using the configuration from Mika's GitHub.";
"Ubisoft Connect" = "ubisoft-connect", "Game store";
"Ventoy" = "ventoy", "A tool for creating bootable USB drives";
"VeraCrypt" = "veracrypt", "File and disk encryption software";
"VirtualBox (NOTE!)" = "virtualbox", "Virtualization platform. NOTE! Cannot be installed on the same computer as Hyper-V. Hardware virtualization should be enabled in BIOS/UEFI before installing.";
"VirtualBox Guest Additions (NOTE!)" = "virtualbox-guest-additions-guest.install", "NOTE! This should be installed inside a virtual machine.";
"VLC" = "vlc", "Video player";
"Visual Studio Code (NOTE!)" = "vscode", "Text editor / IDE. Sends lots of tracking data to Microsoft. Use VSCodium instead.";
"VSCodium" = "vscodium", "Text editor / IDE. Open source version of Visual Studio Code.";
"Wacom drivers" = "wacom-drivers", "Drivers for Wacom drawing tablets";
"WireGuard" = "wireguard", "VPN client";
"Xournal++" = "xournalplusplus", "For taking handwritten notes with a drawing tablet";
"Xerox Global Print Driver PCL/PS V3" = "xeroxupd", "Driver for Xerox printers";
"yt-dlp" = "yt-dlp", "Video downloader for e.g. YouTube";
"YubiKey Manager" = "yubikey-manager", "Management software for the YubiKey hardware security keys";
"Zoom" = "zoom", "Video conferencing";
"Zotero" = "zotero", "Reference and citation management software";
}
$WingetPrograms = [ordered]@{
"PowerShell" = "Microsoft.PowerShell", "The new cross-platform PowerShell (>= 7)";
# The PowerToys version available from WinGet is a preview.
# https://github.com/microsoft/PowerToys#via-winget-preview
# "PowerToys" = "Microsoft.PowerToys";
}
$WindowsCapabilities = [ordered]@{
# "OpenSSH client" = "OpenSSH.Client~~~~0.0.1.0", "NOTE! This is an old version that does not support FIDO2. Install SSH from the other programs menu instead.";
"RSAT AD LDS (Active Directory management tools)" = "Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0", "Active Directory management tools";
"RSAT BitLocker tools" = "Rsat.BitLocker.Recovery.Tools~~~~0.0.1.0", "Active Directory BitLocker management tools";
"RSAT DHCP tools" = "Rsat.DHCP.Tools~~~~0.0.1.0", "Active Directory DHCP management tools";
"RSAT DNS tools" = "Rsat.Dns.Tools~~~~0.0.1.0", "Active Directory DNS management tools";
"RSAT cluster tools" = "Rsat.FailoverCluster.Management.Tools~~~~0.0.1.0", "Server cluster management tools";
"RSAT file server tools" = "Rsat.FileServices.Tools~~~~0.0.1.0", "Active Directory file server management tools";
"RSAT group policy tools" = "Rsat.GroupPolicy.Management.Tools~~~~0.0.1.0", "Active Directory group policy management tools";
# "RSAT network controller tools" = "Rsat.NetworkController.Tools~~~~0.0.1.0", "RSAT network controller tools";
"RSAT Server Manager" = "Rsat.ServerManager.Tools~~~~0.0.1.0", "Remote server management tools";
"RSAT Shielded VM tools" = "Rsat.Shielded.VM.Tools~~~~0.0.1.0", "Management tools for shielded virtual machines";
"RSAT WSUS tools" = "Rsat.WSUS.Tools~~~~0.0.1.0", "Active Directory Windows Update management tools";
"SNMP client" = "SNMP.Client~~~~0.0.1.0", "SNMP remote monitoring client";
}
$WindowsFeatures = [ordered]@{
"Hyper-V (NOTE!)" = "Microsoft-Hyper-V-All", "Virtualization platform. NOTE! Cannot be installed on the same computer as VirtualBox. Hardware virtualization should be enabled in BIOS/UEFI before installing.";
"Hyper-V management tools" = "Microsoft-Hyper-V-Tools-All", "Tools for managing Hyper-V servers, both local and remote";
}
# Installer functions
function Install-AtostekID([string]$Version = "4.4.0.0") {
<#
.LINK
https://dvv.fi/en/card-reader-software
#>
# Get-Package does not work on PowerShell 7
$DigiSign = Get-InstalledSoftware | Where-Object {$_.Name -eq "mPollux DigiSign Client"}
if ($DigiSign) {
Show-Output "Fujitsu mPollux DigiSign Client found. Uninstalling."
Invoke-CimMethod -InputObject $DigiSign -MethodName Uninstall
} else {
Show-Output "Fujitsu mPollux DigiSign Client was not found, so there's no need to uninstall it before installing Atostek ID."
}
$Filename = "AtostekID_WIN_${Version}.msi"
Install-FromUri `
-Name "Atostek ID" `
-Uri "https://files.fineid.fi/download/atostek/${Version}/windows/${Filename}" `
-Filename "${Filename}"
}
function Install-BaslerPylon([string]$Version = "25.10.2") {
<#
.LINK
https://www.baslerweb.com/en/downloads/software/
#>
$Filename = "Basler pylon ${Version}.exe"
$FilenameUrl = [uri]::EscapeDataString($Filename)
Install-FromUri `
-Name "Basler Pylon Camera Software Suite" `
-Uri "https://downloadbsl.blob.core.windows.net/software/pylon%20${Version}/${FilenameUrl}" `
-Filename "${Filename}"
}
function Install-CorelDRAW {
<#
.LINK
https://myaccount.corel.com/perpetual-products
.LINK
https://www.coreldraw.com/en/licensing/download/
#>
Install-FromUri `
-Name "CorelDRAW" `
-Uri "https://www.corel.com/akdlm/6763/downloads/free/trials/GraphicsSuite/22H1/JL83s3fG/CDGS.exe" `
-Filename "CDGS.exe"
}
function Install-DigilentWaveforms([string]$Version = "3.24.4") {
<#
.LINK
https://cloud.digilent.com/myproducts/waveforms
#>
$Filename = "digilent.waveforms_v${Version}_64bit.exe"
Install-FromUri `
-Name "Digilent Waveforms" `
-Uri "https://files.digilent.com/Software/Waveforms/${Version}/${Filename}" `
-Filename "${Filename}"
}
function Install-Eduroam {
<#
.LINK
https://www.eduroam.app/
#>
Install-FromUri `
-Name "Eduroam" `
-Uri "https://dl.eduroam.app/windows/x86_64/geteduroam.exe" `
-Filename "geteduroam.exe"
}
function Install-FDAeSubmitter {
<#
.LINK
https://www.fda.gov/industry/fda-esubmitter/esubmitter-download-and-installation
#>
Install-FromUri -Name "FDA eSubmitter" `
-Uri "https://www.accessdata.fda.gov/esubmissions/ftparea/esubmitter/platforms/Windows/IncludeJvm/jinstall.zip" `
-Filename "jinstall.zip" -UnzippedFilePath "jinstall.exe" `
-SHA256 "b98d19c7ae5daf53f7cb7e552a15f8c5c67609a2ffb4b789cf530f8b6733b6fb" `
-BypassAuthenticode
}
function Install-Git {
<#
.SYNOPSIS
Install Git with Chocolatey and custom parameters
.LINK
https://github.com/chocolatey-community/chocolatey-packages/blob/master/automatic/git.install/ARGUMENTS.md
#>
# if (Get-WindowsCapability -Online -Name "OpenSSH.Client~~~~0.0.1.0") {
# Show-Output "Found Windows integrated OpenSSH client, which the SSH included in Git for Windows should override. Removing."
Remove-WindowsCapability -Online -Name "OpenSSH.Client~~~~0.0.1.0"
# }
Show-Output "Installing Git with Chocolatey and custom parameters"
choco upgrade git.install -y --force --params "/GitAndUnixToolsOnPath /WindowsTerminalProfile"
}
function Install-IDSPeak ([string]$Version = "2.18.1.0", [string]$Version2 = "183") {
<#
.LINK
https://en.ids-imaging.com/download-peak.html
#>
$Folder = "ids-peak-win-extended-setup-64-${Version}"
$Filename = "${Folder}.zip"
Install-FromUri `
-Name "IDS Peak" `
-Uri "https://en.ids-imaging.com/files/downloads/ids-peak/software/windows/${Filename}" `
-Filename "${Filename}" `
-UnzipFolderName "${Folder}" `
-UnzippedFilePath "ids_peak_${Version}-${Version2}_full_with_ueye_runtime.exe"
}
function Install-IDSSoftwareSuite ([string]$Version = "4.95.2", [string]$Version2 = "49520") {
$Folder = "ids-software-suite-win-${Version}"
$Filename = "${Folder}.zip"
Install-FromUri `
-Name "IDS Software Suite (µEye)" `
-Uri "https://en.ids-imaging.com/files/downloads/ids-software-suite/software/windows/${Filename}" `
-Filename "${Filename}" `
-UnzipFolderName "${Folder}" `
-UnzippedFilePath "uEye_${Version2}.exe"
}
function Install-LabVIEWRuntime ([string]$Version = "25.3") {
$Year = $Version.SubString(0,2)
$Filename ="ni-labview-20${Year}-runtime-engine_${Version}_online.exe"
Install-FromUri `
-Name "LabVIEW Runtime" `
-Uri "https://download.ni.com/support/nipkg/products/ni-l/ni-labview-20${Year}-runtime-engine/${Version}/online/${Filename}" `
-Filename "${Filename}"
}
function Install-LabVIEWRuntime2014SP1 {
<#
.SYNOPSIS
Install LabVIEW Runtime 2014 SP1 32-bit
.LINK
https://www.ni.com/en/support/downloads/software-products/download.labview-runtime.html#306243
.DESCRIPTION
Required for SSMbe
#>
$Folder = "LVRTE2014SP1_f11Patchstd"
$Filename = "${Folder}.zip"
Install-FromUri `
-Name "LabVIEW Runtime 2014 SP1 32-bit" `
-Uri "https://download.ni.com/support/softlib/labview/labview_runtime/2014%20SP1/Windows/f11/${Filename}" `
-Filename "${Filename}" `
-UnzipFolderName "${Folder}" `
-UnzippedFilePath "setup.exe" `
-SHA256 "2c54ab5169dd0cc9f14a7b0057881207b6f76e065c7c78bb8c898ac9c5ca0831"
}
function Install-LenovoSuperIOFirmware {
# Lenovo ThinkStation P330 Tiny
if ($ComputerSystem.Model -eq "30CES0B200") {
$InstallerPath = "${SoftwareRepoPath}\Lenovo\P330 Tiny\Firmware\Lenovo Super IO Firmware\m1uct18usa.exe"
$ScriptDir = "${env:SystemDrive}\SWTOOLS\FLASH\M1UCT18USA"
$ScriptPath = "${ScriptDir}\Flash64.cmd"
if (Test-Path "$InstallerPath") {
Start-Process -NoNewWindow -Wait "$InstallerPath" -ArgumentList "/silent"
if (! (Get-YesNo "Did you see the firmware being updated in addition to the flasher being installed?")) {
Show-Output "Since the firmware was not yet updated, updating it now."
Start-Process -NoNewWindow -Wait "cmd.exe" -ArgumentList "/c","cd ${ScriptDir} && ${ScriptPath}"
}
} else {
throw [System.IO.FileNotFoundException] "The Lenovo Super IO firmware installer was not found. Is the network drive mounted?"
}
} else {
throw [System.PlatformNotSupportedException] "No Lenovo Super IO firmware has been configured for your computer model `"$($ComputerSystem.Model)`"."
}
}
function Install-MeerstetterTEC {
<#
.SYNOPSIS
Install Meerstetter TEC Software
.LINK
https://www.meerstetter.ch/customer-center/downloads/category/31-latest-software
#>
# Spaces are not allowed in msiexec filenames. Please also see this issue:
# https://stackoverflow.com/questions/10108517/what-can-cause-msiexec-error-1619-this-installation-package-could-not-be-opened
Install-FromUri `
-Name "Meerstetter TEC software" `
-Uri "https://www.meerstetter.ch/customer-center/downloads/category/31-latest-software?download=764:tec-controller-software" `
-Filename "TEC_Software.msi"
}
function Install-MEFirmware {
# Lenovo ThinkStation P330 Tiny
if ($ComputerSystem.Model -eq "30CES0B200") {
$FilePath = "${SoftwareRepoPath}\Lenovo\P330 Tiny\Firmware\Intel ME Firmware\12.0.90.2072_corporate.exe"
if (Test-Path "$FilePath") {
Start-Process -NoNewWindow -Wait "$FilePath" -ArgumentList "/silent"
} else {
throw [System.IO.FileNotFoundException] "The Intel ME firmware installer was not found. Is the network drive mounted?"
}
} else {
throw [System.PlatformNotSupportedException] "No Intel ME firmware has been configured for your computer model `"$ComputerSystem.Model`"."
}
}
function Install-NI4882 ([string]$Version = "25.8") {
<#
.SYNOPSIS
Install National Instruments NI-488.2
.LINK
https://www.ni.com/fi-fi/support/downloads/drivers/download.ni-488-2.html
#>
$Filename = "ni-488.2_${Version}_online.exe"
Install-FromUri `
-Name "NI 488.2 (GPIB) drivers" `
-Uri "https://download.ni.com/support/nipkg/products/ni-4/ni-488.2/${Version}/online/${Filename}" `
-Filename "${Filename}"
}
function Install-NI-VISA1401Runtime {
<#
.SYNOPSIS
Install NI-VISA 14.0.1 Runtime
.LINK
https://www.ni.com/en/support/downloads/drivers/download.ni-visa.html#306102
.DESCRIPTION
Required for SSMbe.
LabVIEW (runtime) should be installed first,
but this is automatically the case when installing both at the same time with this script,
since LabVIEW comes alphabetically first.
#>
$Folder = "NIVISA1401runtime"
$Filename = "${Folder}.zip"
Install-FromUri `
-Name "NI-VISA 14.0.1 Runtime" `
-Uri "https://download.ni.com/support/softlib/visa/VISA%20Run-Time%20Engine/14.0.1/${Filename}" `
-Filename "${Filename}" `
-UnzipFolderName "${Folder}" `
-UnzippedFilePath "setup.exe" `
-SHA256 "960e0f68ab7dbff286ba8ac2286d4e883f02f9390c2a033b433005e29fb93e72"
}
function Install-OpenVPN {
<#
.SYNOPSIS
Install OpenVPN Community
.NOTES
Not currently used, since OpenVPN is also available from Chocolatey.
.LINK
https://openvpn.net/community-downloads/
#>
param(
[string]$Version = "2.6.15",
[string]$Version2 = "I001"
)
$Arch = Get-InstallBitness -x86 "x86" -x86_64 "amd64"
$Filename = "OpenVPN-${Version}-${Version2}-${Arch}.msi"
Install-FromUri `
-Name "OpenVPN" `
-Uri "https://swupdate.openvpn.org/community/releases/${Filename}" `
-Filename "${Filename}"
}
function Install-OriginLab {
<#
.SYNOPSIS
Install the full version of OriginLab
.LINK
https://www.originlab.com/
#>
param(
[string]$Version = "Origin2022bSr1No_H",
[string]$SHA256 = "08ae9a8a2e75e2d1d19f2b8a74504e83a87623d445ea216dc847da9d00b3f9fc"
)
Install-Executable `
-Name "OriginLab" `
-Path "${SoftwareRepoPath}\Origin\${Version}\setup.exe" `
-SHA256 $SHA256
}
function Install-OriginViewer {
<#
.SYNOPSIS
Install Origin Viewer, the free viewer for Origin data visualization and analysis files
.LINK
https://www.originlab.com/viewer/
#>
Show-Output "Downloading Origin Viewer"
$Arch = Get-InstallBitness -x86 "" -x86_64 "_64"
$Filename = "OriginViewer${Arch}.zip"
Install-FromUri `
-Name "Origin Viewer" `
-Uri "https://www.originlab.com/ftp/${Filename}" `
-Filename "${Filename}" `
-UnzipFolderName "Origin Viewer"
$DestinationPath = "${Downloads}\Origin Viewer"
$ExePath = Find-First -Filter "*.exe" -Path "${DestinationPath}"
if ($null -eq $ExePath) {
throw [System.IO.FileNotFoundException] "No exe file was found in the extracted directory `"${DestinationPath}`"."
}
Test-AuthenticodeSignature -FilePath $ExePath
New-Shortcut `
-Path "${env:APPDATA}\Microsoft\Windows\Start Menu\Programs\Origin Viewer.lnk" `
-TargetPath "${ExePath}"
}
function Install-PicoScope {
<#
.SYNOPSIS
Driver for Pico Tecnology oscilloscopes
.LINK
https://www.picotech.com/downloads/_lightbox/picoscope-7-stable-for-windows
#>
param(
[string]$Version = "7.2.10.7893",
[string]$SHA256 = "4155cfaf8e4cc3bf61f693b6b420bbdacd77f345d3431ccb949e9b6bd81dc51c"
)
$Filename = "PicoScope_7_TandM_${Version}.x64.exe"
Install-FromUri `
-Name "PicoScope" `
-Uri "https://www.picotech.com/download/software/sr/${Filename}" `
-Filename "${Filename}" `
-SHA256 "${SHA256}"
}
function Install-QuPath {
<#
.SYNOPSIS
Bioimage analysis software
.LINK
https://qupath.github.io/
#>
param(
[string]$Version = "0.6.0",
[string]$SHA256 = "fce57283898de252ccba2c781269aa7338f50e981bbd646e309b0e1125deb10c"
)
$Filename = "QuPath-v${Version}-Windows.msi"
Install-FromUri `
-Name "QuPath" `
-Uri "https://github.com/qupath/qupath/releases/download/v${Version}/${Filename}" `
-Filename "${Filename}" `
-SHA256 "${SHA256}" `
-BypassAuthenticode
}
function Install-Rezonator1 {
<#
.SYNOPSIS
Install the reZonator laser cavity simulator
.LINK
http://rezonator.orion-project.org/?page=dload
#>
param(
[string]$Version = "1.7.116.375",
[string]$SHA256 = "c0601dd4de38de638f90ef9314c5d6f5a808cf5dd848f4a02ac7382b71d43ad6"
)
$Filename = "rezonator-${Version}.exe"
# The reZonator web page does not support HTTPS.
Install-FromUri `
-Name "reZonator 1" `
-Uri "https://rezonator.orion-project.org/files/${Filename}" `
-Filename "${Filename}" `
-SHA256 "${SHA256}" `
-BypassAuthenticode
}
function Install-Rezonator2 {
<#
.SYNOPSIS
Install the reZonator 2 laser cavity simulator
.LINK
http://rezonator.orion-project.org/?page=dload
#>
[OutputType([bool])]
param(
[string]$Version = "2.1.1"
)
$Bitness = Get-InstallBitness -x86 "x32" -x86_64 "x64"
$Filename = "rezonator-${Version}-win-${Bitness}.zip"
Install-FromUri `
-Name "reZonator 2" `
-Uri "https://github.com/orion-project/rezonator2/releases/download/v${Version}/${Filename}" `
-Filename $Filename `
-UnzipFolderName "reZonator 2"
New-StartMenuShortcut -Name "reZonator 2" -TargetPath "${Downloads}\reZonator 2\rezonator.exe"
}
function Install-SMCThermoChiller {
<#
.SYNOPSIS
Monitoring software for SMC ThermoChillers, especially the HRR series
.LINK
https://smc-fluidcontrol.com/hrr-software/
#>
param(
[string]$Version = "2.0.1.0",
[string]$SHA256 = "cbb67f4b4e185c708c7dec523087b156c74eab816c136dbbeb1dd7f7dc1d5cb3"
)
$Folder = "hrr-v${Version}"
$Filename = "${Folder}.zip"
Install-FromUri `
-Name "SMC ThermoChiller" `
-Uri "https://static.smc.eu/binaries/content/assets/smc_global/products/engineering-tools/hrr-monitoring-software/${Filename}" `
-Filename "${Filename}" `
-UnzipFolderName "${Folder}" `
-UnzippedFilePath "HRR V${Version}.exe" `
-SHA256 "${SHA256}" `
-BypassAuthenticode
}
function Install-SNLO {
param(
[string]$Version = "78",
[string]$SHA256 = "be4635f51f6d6f51433c660dc4787a256796fb9d35425605f212ff1a60aeba0a"
)
$Filename = "SNLO-v${Version}.exe"
Install-FromUri `
-Name "SNLO" `
-Uri "https://as-photonics.com/snlo_files/${Filename}" `
-Filename "${Filename}" `
-SHA256 "${SHA256}" `
-BypassAuthenticode
}
function Install-SSMbe {
param(
[string]$Version = "20160525",
[string]$SHA256 = "20f1648d44a3bef1c7d1fae0b9973c846c0ea644ce6d0c405c03c558e05894c0"
)
$FolderName = "SSMbe_exe_${Version}"
Install-FromUri `
-Name "SSMbe" `
-Uri "${SoftwareRepoPath}\SS10-1 MBE software\${FolderName}.zip" `
-SHA256 $SHA256
New-StartMenuShortcut -Name "SSMbe" -TargetPath "${Downloads}\${FolderName}\SSMbe.exe"
}
function Install-StarLab {
<#
.SYNOPSIS
Install Ophir StarLab
.LINK
https://www.ophiropt.com/laser--measurement/software/starlab-for-usb
#>
$Filename="StarLab.zip"
Install-FromUri `
-Name "Ophir StarLab" `
-Uri "https://www.ophiropt.com/mam/celum/celum_assets/op/resources/${Filename}" `
-Filename "${Filename}" `
-UnzippedFilePath "StarLab_Setup.exe"
}
function Install-ThorCam ([string]$Version = "3.7.0.6") {
<#
.SYNOPSIS
Install ThorLabs ThorCam
.LINK
https://www.thorlabs.com/software-pages/thorcam
#>
$Arch = Get-InstallBitness -x86 "x86" -x86_64 "x64"
$Filename = "thorlabs-scientific-imaging-software-${Arch}.exe"
if ("${Arch}" -eq "x86") {
$Uri = "https://media.thorlabs.com/contentassets/766069a3302a46a48e6534be6b332b42/${Filename}?v=1116040429"
$SHA256 = "042505509c0546d9e6c8ea16befb70997e363c235b38a02df6251a18ebb19c78"
} else {
$Uri = "https://media.thorlabs.com/contentassets/9f7e1f0b3cff4e9a8c18a3dfa4a0bc0a/${Filename}?v=1116040439"
$SHA256 = "a98f58e484920fc31795b8bd5d65529bb6ee7d296424c496aa659c2bafb4861c"
}
Install-FromUri `
-Name "Thorlabs ThorCam" `
-Uri "${Uri}" `
-Filename "${Filename}" `
-SHA256 "${SHA256}"
}
function Install-ThorImageCAM {
<#
.SYNOPSIS
Install ThorLabs ThorImageCAM
.LINK
https://www.thorlabs.com/software-pages/thorcam
#>
param(
[string]$Version = "1.2.17",
[string]$SHA256 = "1379ea68f248cd32e99e6a69a961d8494f2ff9258c81fe9cefbebd681eb6a800"
)
$Filename = "thorimagecam_v${Version}_setup.exe"
Install-FromUri `
-Name "Thorlabs ThorImageCAM" `
-Uri "https://media.thorlabs.com/contentassets/be3cd1548455438293b1611d70ccb6da/${Filename}?v=1116040425" `
-Filename "${Filename}" `
-SHA256 "${SHA256}"
}
function Install-ThorlabsBeam {
<#
.SYNOPSIS
Install Thorlabs Beam
.LINK
https://www.thorlabs.com/en/software-pages/beam
#>
param(
[string]$Version = "9.3.6304.790",
[string]$SHA256 = "bb4e77c82bf5f227f2e3c6b6a8de43f3821826c2aa4900789282ee14c3367220"
)
$Filename = "thorlabs.thorlabsbeamsetup-release.${Version}_nsis.zip"
Install-FromUri `
-Name "Thorlabs Beam" `
-Uri "https://media.thorlabs.com/contentassets/bcb47aa2aa704177b02ee0c293d15f1a/${Filename}?v=1118090216" `
-Filename "${Filename}" `
-UnzippedFilePath "Thorlabs Beam Setup.exe" `
-SHA256 "${SHA256}"
}
function Install-ThorlabsElliptec ([string]$Version = "1.6.6") {
<#
.SYNOPSIS
Install Thorlabs Elliptec software
.LINK
https://www.thorlabs.com/software-pages/ell
#>
$Arch = Get-InstallBitness -x86 "x86" -x86_64 "x64"
if ("${Arch}" -eq "x86") {
$Uri = "https://media.thorlabs.com/contentassets/d42094d0a1ff4b39a2cc2a61543c7481/setup.exe?v=1116040935"
$SHA256 = "9f371175c22bb96d64370ea4854d64296ff7326b608e09103af3ddf658b9a4c0"
} else {
$Uri = "https://media.thorlabs.com/contentassets/65384a0c619f4a17a721930570bcae87/setup.exe?v=1116040938"
$SHA256 = "dd095269ed5fb7bc5676f5ba86a1f37b3db6e133480f8d29099863fdf90b9299"
}
Install-FromUri `
-Name "Thorlabs Elliptec" `
-Filename "Thorlabs Elliptec setup ${Arch}.exe" `
-Uri "${Uri}" `
-SHA256 "${SHA256}"
}
function Install-ThorlabsKinesis {
<#
.SYNOPSIS
Install Thorlabs Kinesis
.LINK
https://www.thorlabs.com/software-pages/motion_control/
#>
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification="Thorlabs Kinesis is a singular noun")]
param(
[string]$Version = "1.14.59",
[string]$Version2 = "26708"
)
$Arch = Get-InstallBitness -x86 "x86" -x86_64 "x64"
$Filename = "thorlabs_kinesis_setup_${Version2}_${Arch}.exe"
if ("${Arch}" -eq "x86") {
$Uri = "https://media.thorlabs.com/contentassets/fb56e416e2b248f5a7888aae3fcf71d3/${Filename}?v=0126103520"
$SHA256 = "fe073773316e6ca472eeeb47cafaada8324303c6d9a1e25788875fcafd27d888"
} else {
$Uri = "https://media.thorlabs.com/contentassets/98b8893ed3ff41cc8b1794e39e81e6fe/${Filename}?v=0126103405"
$SHA256 = "12240a38699d2fa9a0974daccb52a0f66867b394963e52fcc964f2d42ba6b88e"
}
Install-FromUri `
-Name "Thorlabs Kinesis" `
-Filename "${Filename}" `
-Uri "${Uri}" `
-SHA256 "${SHA256}"
}
function Install-VCU {
param(
[string]$Version = "0.13.42",
[string]$SHA256 = "d1a20b6a24bd2bff8ee9bb8cd6aca1200a47e6f5e86eebf8fb053100751255e6"
)
Install-Executable `
-Name "VCU GUI" `
-Path "${SoftwareRepoPath}\VCU\VCU_GUI_Setup_${Version}.exe" `
-SHA256 "${SHA256}" `
-BypassAuthenticode
}
function Install-VCURemote2 {
[OutputType([int])]
param(
[string]$Version = "250805"
)
$Folder = "vcu_remote2_${Version}"
Install-FromUri `
-Name "VCU Remote 2" `
-Uri "${SoftwareRepoPath}\VCU\${Folder}.zip" `
-SHA256 "30adc530bb6b40ff527ca183ed21c0617d0e3cadc8e39a6f937b3a87df4903d7"
New-StartMenuShortcut -Name "VCU Remote 2" -TargetPath "${Downloads}\${Folder}\vcu-remote2.exe"
}
function Install-VeecoVision {
Install-FromUri `
-Name "Veeco (Wyko) Vision" `
-Uri "${SoftwareRepoPath}\Veeco\VISION64_V5.51_Release.zip" `
-UnzippedFilePath "CD 775-425 SOFTWARE VISION64 V5.51\Install.exe" `
-SHA256 "49601df2ca6f6668f342b776d67c533841b6de2b43f531ff70f636fd5ef87af8"
Install-FromUri `
-Name "Veeco (Wyko) Vision update" `
-Uri "${SoftwareRepoPath}\Veeco\Vision64 5.51 Update 3.zip" `
-UnzippedFilePath "Vision64 5.51 Update 3\CD\Vision64_5.51_Update_3.EXE" `
-SHA256 "43ecbd255d7830029337a489e0219536b860a4858672378ce6d9d78c60cbc5df" `
-BypassAuthenticode
}
function Install-Wavesquared {
param(
[string]$Version = "4.4.2.25284",
[string]$SHA256 = "5fd66f23fe6dfdcae781936b9f52a46a216da455707922ae8dd905e4c710ec6e"
)
# https://jrsoftware.org/ishelp/index.php?topic=setupcmdline
Install-Executable `
-Name "Wavesquared" `
-Path "${SoftwareRepoPath}\Imagine Optic\wavesquared_${Version}\WaveSuite_setup.exe" `
-SHA256 $SHA256 `
-BypassAuthenticode
}
function Install-WithSecure {
Install-Executable -Name "WithSecure" -Path "${SoftwareRepoPath}\WithSecure\ElementsAgentInstaller*.exe"
}
function Install-WSL {
if (Test-CommandExists "wsl") {
Show-Output "Installing Windows Subsystem for Linux (WSL), version >= 2"
wsl --install
} else {
Show-Output -ForegroundColor Red "The installer command for Windows Subsystem for Linux (WSL) was not found. Are you running an old version of Windows?"
}
}
function Install-Xeneth {
param(
[string]$Version = "BOBCAT320-9851_RMA18001067",
[string]$SHA256 = "acde5c53ef46595de5dee77a0b0e59cd1d6e15e4be0ae27b5257ddec039ff7f7"
)
# $Bitness = Get-InstallBitness -x86 "" -x86_64 "64"
$FilePath = "${SoftwareRepoPath}\Xenics\${Version}\Software\Xeneth-Setup64.exe"
Install-Executable `
-Name "Xeneth" `
-Path "${FilePath}" `
-SHA256 $SHA256 `
-BypassAuthenticode
}
$OtherOperations = [ordered]@{
"Atostek ID" = ${function:Install-AtostekID}, "Card reader software for Finnish identity cards";
"Basler Pylon" = ${function:Install-BaslerPylon}, "Driver for Basler cameras";
"CorelDRAW" = ${function:Install-CorelDRAW}, "Graphic design, illustration and technical drawing software. Requires a license.";
"Digilent Waveforms" = ${function:Install-DigilentWaveforms}, "Measurement software for Digilent lab devices";
"Eduroam" = ${function:Install-Eduroam}, "University Wi-Fi";
"FDA eSubmitter" = ${function:Install-FDAeSubmitter}, "Utility for submitting information to the U.S. Food & Drug Administration";
# "Fujitsu mPollux DigiSign" = ${function:Install-DigiSign}, "Card reader software for Finnish identity cards";
"Geekbench" = ${function:Install-Geekbench}, "Performance testing utility, versions 2-5. Commercial use requires a license.";
"Git" = ${function:Install-Git}, "Git with custom arguments (SSH available from PATH etc.)";
"IDS Peak" = ${function:Install-IDSPeak}, "Driver for IDS cameras and old Thorlabs cameras";
"IDS Software Suite (µEye, NOTE!)" = ${function:Install-IDSSoftwareSuite}, "Driver for old IDS/Thorlabs cameras. NOTE! IDS Peak should now be compatible also with these old cameras, so use it instead.";
"Intel ME firmware" = ${function:Install-MEFirmware}, "Intel Management Engine firmware";
# "LabVIEW Runtime" = ${function:Install-LabVIEWRuntime}, "Required for running LabVIEW-based applications";
"LabVIEW Runtime 2014 SP1 32-bit" = ${function:Install-LabVIEWRuntime2014SP1}, "Required for SSMbe (it requires this specific older version instead of the latest)";
"Lenovo Super IO firmware" = ${function:Install-LenovoSuperIOFirmware}, "Firmware for the IO chip on Lenovo motherboards";
"Meerstetter TEC Software" = ${function:Install-MeerstetterTEC}, "Driver for Meerstetter TEC controllers";
"NI 488.2 (GPIB)" = ${function:Install-NI4882}, "National Instruments GPIB drivers. Includes NI-VISA.";
"NI-VISA 14.0.1 Runtime" = ${function:Install-NI-VISA1401Runtime}, "Required for SSMbe (it requires this specific older version instead of the latest)";
# OpenVPN is also available from Chocolatey.
# Use this manual version only when the package version in Chocolatey is too old.
# "OpenVPN" = ${function:Install-OpenVPN}, "VPN client";
"Ophir StarLab" = ${function:Install-StarLab}, "Driver for Ophir power meters";
"OriginLab" = ${function:Install-OriginLab}, "OriginLab data graphing and analysis software";
"Origin Viewer" = ${function:Install-OriginViewer}, "Viewer for OriginLab data graphing and analysis files";
"Phoronix Test Suite" = ${function:Install-PTS}, "Performance testing framework";
"PicoScope" = ${function:Install-PicoScope}, "Driver for Pico Technology oscilloscopes";
"QuPath" = ${function:Install-QuPath}, "Bioimage analysis software";
"reZonator 1" = ${function:Install-Rezonator1}, "Simulator for optical cavities (old stable version)";
"reZonator 2" = ${function:Install-Rezonator2}, "Simulator for optical cavities (new beta version)";
"SMC ThermoChiller" = ${function:Install-SMCThermoChiller}, "Monitoring software for SMC ThermoChillers, especially the HRR series";
"SNLO" = ${function:Install-SNLO}, "Crystal nonlinear optics simulator";
"SSMbe (NOTE!)" = ${function:Install-SSMbe}, "Control software for the SS10-1 MBE reactor. NOTE! Also install the LabVIEW Runtime and NI-VISA dependencies.";
"Thorlabs ThorCam" = ${function:Install-ThorCam}, "Driver for old Thorlabs cameras. NOTE! Use IDS Peak instead for the oldest cameras.";
"Thorlabs ThorImageCAM" = ${function:Install-ThorImageCAM}, "Driver for Thorlabs cameras.";
"Thorlabs Beam" = ${function:Install-ThorlabsBeam}, "Driver for Thorlabs beam profilers and M2 measurement systems";
"Thorlabs Elliptec" = ${function:Install-ThorlabsElliptec}, "Driver for Thorlabs Elliptec stages and mounts";
"Thorlabs Kinesis" = ${function:Install-ThorlabsKinesis}, "Driver for Thorlabs motors and stages";
"VCU" = ${function:Install-VCU}, "VCU GUI";
"VCU Remote 2" = ${function:Install-VCURemote2}, "VCU Remote 2";
"Veeco (Wyko) Vision" = ${function:Install-VeecoVision}, "Data analysis tool for Veeco/Wyko profilers";
"Wavesquared" = ${function:Install-Wavesquared}, "M2 factor analysis software";
"Windows Subsystem for Linux (WSL, NOTE!)" = ${function:Install-WSL}, "Compatibility layer for running Linux applications on Windows, version >= 2. Hardware virtualization should be enabled in BIOS/UEFI before installing.";
"WithSecure Elements Agent" = ${function:Install-WithSecure}, "Anti-virus. Requires a license.";
"Xeneth" = ${function:Install-Xeneth}, "Driver for Xenics cameras";
# These are the last on purpose
"Maintenance" = "${PSScriptRoot}\Maintenance.ps1", "Run the maintenance script";
"Report" = "${PSScriptRoot}\Report.ps1", "Run the reporting script";
}
#####
# GUI functions
#####
# Function definitions should be after the loading of utilities
function New-List {
<#
.SYNOPSIS
Create a GUI element for selecting options from a list with checkboxes
.LINK
https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.checkedlistbox
#>
[OutputType([system.Windows.Forms.CheckedListBox])]
param(
[Parameter(mandatory=$true)][System.Object]$Parent,
[Parameter(mandatory=$true)][String]$Title,
[Parameter(mandatory=$true)][String[]]$Options,
[int]$Width = $GlobalWidth
)
# Title label
$Label = New-Object System.Windows.Forms.Label
$Label.Text = $Title;
$Label.Width = $Width;
$Parent.Controls.Add($Label);
# Create a CheckedListBox
$List = New-Object -TypeName System.Windows.Forms.CheckedListBox;
$Parent.Controls.Add($List);
$List.Items.AddRange($Options);
$List.CheckOnClick = $true;
$List.Width = $Width;
$List.Height = $Options.Count * 17 + 18;
return $List;
}
function New-Table {
<#
.SYNOPSIS
Create a GUI element for selecting items from a list with checboxes
.LINK
https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.datagridview
#>
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidAssignmentToAutomaticVariable", "sender", Justification="Probably used by library code")]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "e", Justification="Probably used by library code")]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "sender", Justification="Probably used by library code")]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "Form", Justification="Reserved for future use")]
[OutputType([system.Windows.Forms.DataGridView])]
param(
[Parameter(mandatory=$true)][System.Object]$Form,
[Parameter(mandatory=$true)][System.Object]$Parent,
[Parameter(mandatory=$true)][String]$Title,
[Parameter(mandatory=$true)]$Data
# [int]$Width = $GlobalWidth
)
# Title label
$Label = New-Object System.Windows.Forms.Label;
$Label.Text = $Title;
# $Label.MinimumSize = New-Object System.Drawing.Size($Width, 0);
$Label.Anchor = `
[System.Windows.Forms.AnchorStyles]::Top -bor `
[System.Windows.Forms.AnchorStyles]::Bottom -bor `
[System.Windows.Forms.AnchorStyles]::Left -bor `
[System.Windows.Forms.AnchorStyles]::Right
$Parent.Controls.Add($Label);
# Create the DataTable
$Table = New-Object system.Data.DataTable;
$Col = New-Object system.Data.DataColumn "Selected", ([bool]);
$Table.Columns.Add($Col);
$Col = New-Object system.Data.DataColumn "Name", ([string]);
$Table.Columns.Add($Col);
$Col = New-Object system.Data.DataColumn "Description", ([string]);
$Table.Columns.Add($Col);
$Col = New-Object system.Data.DataColumn "Command", ([Object]);
$Table.Columns.Add($Col);
# Fill the DataTable
foreach($element in $Data.GetEnumerator()) {
$row = $Table.NewRow();
$row.Selected = $false;
$row.Name = $element.Name;
$row.Description = $element.Value[1];
$row.Command = $element.Value[0];
$Table.Rows.Add($row);
}
# Create the DataGridView
$View = New-Object system.Windows.Forms.DataGridView;
$View.DataSource = $Table;
$View.AllowUserToAddRows = $false;
$View.AllowUserToDeleteRows = $false;
$View.AllowUserToOrderColumns = $false;
$View.AllowUserToResizeColumns = $false;
$View.AllowUserToResizeRows = $false;
$View.AutoSizeColumnsMode = "AllCells";
$View.ShowEditingIcon = $false;
# This enables the desired resizing behaviour, but does not work properly without AutoSizeMode or equivalent.
# $View.AutoSize = $true;
# This property does not exist for DataGridView.
# $View.AutoSizeMode = [System.Windows.Forms.AutoSizeMode]::GrowAndShrink;
# $View.Height = $Data.Count * 25 + 50;
# $View.Width = $Width;
$View.Anchor = `
[System.Windows.Forms.AnchorStyles]::Top -bor `
[System.Windows.Forms.AnchorStyles]::Bottom -bor `
[System.Windows.Forms.AnchorStyles]::Left -bor `
[System.Windows.Forms.AnchorStyles]::Right
# https://forums.powershell.org/t/datagridview-hide-column/16739
# https://stackoverflow.com/a/23763025/
$dataBindingComplete = {
param (
[object]$sender,
[System.EventArgs]$e
)
Show-Output "Locking the UI from modifications and hiding unnecessary columns. (This does not work yet.)";
# Show-Output $View.Columns;
foreach($column in $View.Columns) {
if ($column.Name -ne "Selected") {
$column.ReadOnly = $true;
}
}