Reworked setup function

This commit is contained in:
2023-11-06 09:28:37 +01:00
parent 2a376e3e66
commit 50cdda2a3d

View File

@@ -21,43 +21,109 @@ $scriptUrls = @(
Import-ScriptsFromUrls -ScriptUrls $scriptUrls Import-ScriptsFromUrls -ScriptUrls $scriptUrls
function SetupLabo { function Setup {
Write-Host "Performing Labo Installation..." param (
DownloadFiles -Type "Labo" [string] $Type
)
Write-Host "Performing $Type Installation..."
DownloadFiles -Type $Type
CheckOfficeInstall CheckOfficeInstall
SetupUsers SetupUsers
SetupEleveReg -username "Eleve" SetupEleveReg -username "Eleve"
EnableRDP EnableRDP
InstallChoco InstallChoco
ChocoInstallApps -Type "Labo" ChocoInstallApps -Type $Type
InstallApps -Type "Labo" InstallApps -Type $Type
UpdateWindows UpdateWindows
Write-Host "Installation complete!"
} }
function SetupInfo { function Custom {
Write-Host "Performing Info Installation..." # ask user if they need to download files
DownloadFiles -Type "Info" $input = Read-Host "Do you need to download files? (y/n)"
CheckOfficeInstall if ($input -eq "y") {
SetupUsers $DownloadFiles = @()
SetupEleveReg -username "Eleve" do {
EnableRDP $input = Read-Host "Enter the URL of the file you want to download (leave empty to stop)"
InstallChoco if ($input -ne "") {
ChocoInstallApps -Type "Info" $DownloadFiles += $input
InstallApps -Type "Info" }
UpdateWindows } while ($input -ne "")
}
# ask user if they need to install office
$input = Read-Host "Do you need to install Office? (y/n)"
if ($input -eq "y") {
$Office = $true
}
# ask user if they need to setup users
$input = Read-Host "Do you need to setup users? (y/n)"
if ($input -eq "y") {
$Users = $true
# ask user if they need to setup eleve registry
$input = Read-Host "Do you need to setup eleve registry? (y/n)"
if ($input -eq "y") {
$EleveReg = $true
}
}
# ask user if they need to enable RDP
$input = Read-Host "Do you need to enable RDP? (y/n)"
if ($input -eq "y") {
$RDP = $true
}
# ask user if they need to install chocolatey
$input = Read-Host "Do you need to install chocolatey? (y/n)"
if ($input -eq "y") {
$Choco = $true
# ask user if they need to install chocolatey apps
$input = Read-Host "Do you need to install chocolatey apps? (y/n)"
if ($input -eq "y") {
$ChocoApps = @()
do {
$input = Read-Host "Enter the name of the app you want to install (leave empty to stop)"
if ($input -ne "") {
$ChocoApps += $input
}
} while ($input -ne "")
}
}
# ask user if they need to install apps
$input = Read-Host "Do you need to install apps? (y/n)"
if ($input -eq "y") {
$Apps = @()
do {
$input = Read-Host "Enter the name of the app you want to install (leave empty to stop)"
if ($input -ne "") {
$Apps += $input
}
} while ($input -ne "")
}
# ask user if they need to update windows
$input = Read-Host "Do you need to update windows? (y/n)"
if ($input -eq "y") {
$Update = $true
}
SetupCustom -DownloadFiles $DownloadFiles -Office $Office -Users $Users -EleveReg $EleveReg -RDP $RDP -Choco $Choco -ChocoApps $ChocoApps -Apps $Apps -Update $Update
} }
function SetupLaptop { function SetupCustom {
Write-Host "Performing Laptop Installation..." param (
DownloadFiles -Type "Laptop" [array] $DownloadFiles,
CheckOfficeInstall [bool] $Office,
SetupUsers [bool] $Users,
SetupEleveReg -username "Eleve" [bool] $EleveReg,
EnableRDP [bool] $RDP,
InstallChoco [bool] $Choco,
ChocoInstallApps -Type "Laptop" [array] $ChocoApps,
InstallApps -Type "Laptop" [array] $Apps,
UpdateWindows [bool] $Update
)
Write-Host "Performing Custom Installation..."
if ($DownloadFiles) {
DownloadFiles -Files $DownloadFiles
}
if ($Office) {
CheckOfficeInstall
}
} }
function Show-InstallationMenu { function Show-InstallationMenu {
@@ -72,9 +138,10 @@ function Show-InstallationMenu {
$selection = Read-Host "Enter the number of your choice" $selection = Read-Host "Enter the number of your choice"
switch ($selection) { switch ($selection) {
"1" { SetupLabo } "1" { Setup -Type "Labo" }
"2" { SetupInfo } "2" { Setup -Type "Info" }
"3" { SetupLaptop } "3" { Setup -Type "Laptop" }
"4" { Custom }
default { Write-Host "Invalid selection. Please choose 1, 2, or 3." } default { Write-Host "Invalid selection. Please choose 1, 2, or 3." }
} }
} while ($selection -ne "1" -and $selection -ne "2" -and $selection -ne "3") } while ($selection -ne "1" -and $selection -ne "2" -and $selection -ne "3")