165 lines
4.2 KiB
PowerShell
165 lines
4.2 KiB
PowerShell
function Import-ScriptsFromUrls {
|
|
param (
|
|
[string[]] $ScriptUrls,
|
|
[string] $LocalPath
|
|
)
|
|
|
|
$scripts = @()
|
|
|
|
foreach ($url in $ScriptUrls) {
|
|
$fileName = Split-Path -Leaf $url
|
|
$localFile = Join-Path -Path $LocalPath -ChildPath $fileName
|
|
Write-Host "Downloading script $fileName to $localFile"
|
|
Invoke-WebRequest -Uri $url -OutFile $localFile -UseBasicParsing
|
|
Write-Host "Importing script from $localFile"
|
|
$scripts += $localFile
|
|
}
|
|
|
|
return $scripts
|
|
}
|
|
|
|
$baseUrl = "https://git.justw.tf/Lightemerald/setup-script/raw/branch/main/"
|
|
$scriptUrls = @(
|
|
($baseUrl + "setupTmp.ps1"),
|
|
($baseUrl + "setupOffice.ps1"),
|
|
($baseUrl + "setupUsers.ps1"),
|
|
($baseUrl + "setupReg.ps1"),
|
|
($baseUrl + "setupChoco.ps1"),
|
|
($baseUrl + "setupApps.ps1"),
|
|
($baseUrl + "setupUpdate.ps1"),
|
|
($baseUrl + "setupWDAC.ps1")
|
|
)
|
|
|
|
$scripts = Import-ScriptsFromUrls -ScriptUrls $scriptUrls -LocalPath (Join-Path $env:LOCALAPPDATA "Temp")
|
|
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process -Force
|
|
foreach ($script in $scripts) {
|
|
. $script
|
|
}
|
|
|
|
|
|
function Setup {
|
|
param (
|
|
[string] $Type
|
|
)
|
|
Write-Host "Performing $Type Installation..."
|
|
DownloadFiles -Type $Type
|
|
CheckOfficeInstall
|
|
SetupUsers
|
|
SetupEleveReg -username "Eleve"
|
|
EnableRDP
|
|
InstallChoco
|
|
ChocoInstallApps -Type $Type
|
|
InstallApps -Type $Type
|
|
UpdateWindows
|
|
Write-Host "Installation complete!"
|
|
}
|
|
|
|
function Custom {
|
|
|
|
$input = Read-Host "Do you need to install Office? (y/n)"
|
|
if ($input -eq "y") {
|
|
$Office = $true
|
|
}
|
|
|
|
$input = Read-Host "Do you need to setup users? (y/n)"
|
|
if ($input -eq "y") {
|
|
$Users = $true
|
|
|
|
$input = Read-Host "Do you need to setup eleve registry? (y/n)"
|
|
if ($input -eq "y") {
|
|
$EleveReg = $true
|
|
}
|
|
}
|
|
|
|
$input = Read-Host "Do you need to enable RDP? (y/n)"
|
|
if ($input -eq "y") {
|
|
$RDP = $true
|
|
}
|
|
|
|
$input = Read-Host "Do you need to install chocolatey? (y/n)"
|
|
if ($input -eq "y") {
|
|
$Choco = $true
|
|
|
|
$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 "")
|
|
}
|
|
}
|
|
|
|
$input = Read-Host "Do you need to update windows? (y/n)"
|
|
if ($input -eq "y") {
|
|
$Update = $true
|
|
}
|
|
SetupCustom -Office $Office -Users $Users -EleveReg $EleveReg -RDP $RDP -Choco $Choco -ChocoApps $ChocoApps -Update $Update
|
|
}
|
|
|
|
function SetupCustom {
|
|
param (
|
|
[bool] $Office,
|
|
[bool] $Users,
|
|
[bool] $EleveReg,
|
|
[bool] $RDP,
|
|
[bool] $Choco,
|
|
[array] $ChocoApps,
|
|
[bool] $Update
|
|
)
|
|
Write-Host "Performing Custom Installation..."
|
|
if ($Office) {
|
|
CheckOfficeInstall
|
|
}
|
|
if ($Users) {
|
|
SetupUsers
|
|
if ($EleveReg) {
|
|
SetupEleveReg -username "Eleve"
|
|
}
|
|
}
|
|
if ($RDP) {
|
|
EnableRDP
|
|
}
|
|
if ($Choco) {
|
|
InstallChoco
|
|
if ($ChocoApps) {
|
|
ChocoInstallApps -Type "Custom" -Apps $ChocoApps
|
|
}
|
|
}
|
|
if ($Update) {
|
|
UpdateWindows
|
|
}
|
|
}
|
|
|
|
function Show-InstallationMenu {
|
|
$selection = $null
|
|
|
|
do {
|
|
Write-Host "Which type of installation would you like to perform?"
|
|
Write-Host "1. Labo"
|
|
Write-Host "2. Info"
|
|
Write-Host "3. Laptop"
|
|
|
|
$selection = Read-Host "Enter the number of your choice"
|
|
|
|
switch ($selection) {
|
|
"1" { Setup -Type "Labo" }
|
|
"2" { Setup -Type "Info" }
|
|
"3" { Setup -Type "Laptop" }
|
|
"4" { Custom }
|
|
default { Write-Host "Invalid selection. Please choose 1, 2, or 3." }
|
|
}
|
|
} while ($selection -ne "1" -and $selection -ne "2" -and $selection -ne "3")
|
|
}
|
|
|
|
Show-InstallationMenu
|
|
EnableWDAC
|
|
|
|
Write-Host "Would you like to restart now? (y/n)"
|
|
$input = Read-Host
|
|
if ($input -eq "y") {
|
|
Clear-RecycleBin
|
|
Restart-Computer
|
|
} |