forked from ChrisTitusTech/win10script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.ps1
64 lines (55 loc) · 1.49 KB
/
test.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
###
### Test bed for new menus
###
$tweaks = @(
"InstallNotepadplusplus"
)
function Show-Choco-Menu {
param(
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string]$Title,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string]$ChocoInstall
)
do
{
Clear-Host
Write-Host "================ $Title ================"
Write-Host "Y: Press 'Y' to do this."
Write-Host "2: Press 'N' to skip this."
Write-Host "Q: Press 'Q' to stop the entire script."
$selection = Read-Host "Please make a selection"
switch ($selection)
{
'y' { choco install $ChocoInstall }
'n' { Break }
'q' { Exit }
}
pause
}
until ($selection -match "y" -or $selection -match "n" -or $selection -match "q")
}
Function InstallNotepadplusplus {
Show-Choco-Menu -Title "Do you want to install Notepad++?" -ChocoInstall "notepadplusplus"
}
##########
# Parse parameters and apply tweaks
##########
# Normalize path to preset file
$preset = ""
$PSCommandArgs = $args
If ($args -And $args[0].ToLower() -eq "-preset") {
$preset = Resolve-Path $($args | Select-Object -Skip 1)
$PSCommandArgs = "-preset `"$preset`""
}
# Load function names from command line arguments or a preset file
If ($args) {
$tweaks = $args
If ($preset) {
$tweaks = Get-Content $preset -ErrorAction Stop | ForEach { $_.Trim() } | Where { $_ -ne "" -and $_[0] -ne "#" }
}
}
# Call the desired tweak functions
$tweaks | ForEach { Invoke-Expression $_ }