192 lines
6.2 KiB
PowerShell
192 lines
6.2 KiB
PowerShell
$baseUrl = "https://git.justw.tf/Lightemerald/setup-script/raw/branch/main/"
|
|
$scriptUrls = @(
|
|
($baseUrl + "setupTmp.ps1"),
|
|
($baseUrl + "setupOffice.ps1"),
|
|
($baseUrl + "setupActivate.ps1"),
|
|
($baseUrl + "setupUsers.ps1"),
|
|
($baseUrl + "setupReg.ps1"),
|
|
($baseUrl + "setupRDP.ps1"),
|
|
($baseUrl + "setupChoco.ps1"),
|
|
($baseUrl + "setupApps.ps1"),
|
|
($baseUrl + "setupUpdate.ps1"),
|
|
($baseUrl + "setupWDAC.ps1")
|
|
)
|
|
|
|
function OldImportModules {
|
|
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process -Force
|
|
foreach ($url in $ScriptUrls) {
|
|
$fileName = Split-Path -Leaf $url
|
|
$localFile = Join-Path -Path $(Join-Path $env:LOCALAPPDATA "Temp") -ChildPath $fileName
|
|
Write-Host "Downloading script $fileName to $localFile"
|
|
Invoke-WebRequest -Uri $url -OutFile $localFile -UseBasicParsing
|
|
Write-Host "Importing script from $localFile"
|
|
. $localFile
|
|
}
|
|
}
|
|
|
|
function ImportModules {
|
|
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process -Force
|
|
foreach ($ScriptUrl in $ScriptUrls) {
|
|
try {
|
|
Write-Host "Importing script from $ScriptUrl"
|
|
$scriptContent = Invoke-RestMethod $ScriptUrl
|
|
Invoke-Expression $scriptContent
|
|
} catch {
|
|
Write-Error "Error importing script from $ScriptUrl. Error: $_"
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
function StandardSetup {
|
|
param (
|
|
[string] $Type
|
|
)
|
|
Write-Host "Performing $Type Installation..."
|
|
DownloadFiles -Type $Type
|
|
SetupOffice
|
|
SetupActivaton
|
|
SetupUser -username "Eleve" -password "" -description "Compte élève" -group "Users"
|
|
SetupUser -username "Prof" -password "IPRprof2398" -description "Compte professeur" -group "Users"
|
|
SetupUser -username "Admin" -password "Lprsnm4ehk26-" -description "Compte administrateur" -group "Administrators"
|
|
SetupUserReg -username "Eleve"
|
|
EnableRDP
|
|
InstallChoco
|
|
ChocoInstallApps -Type $Type
|
|
InstallApps -Type $Type
|
|
UpdateWindows
|
|
Show-WDACMenu
|
|
Write-Host "Installation complete!"
|
|
Write-Host "Would you like to restart now? (y/n)"
|
|
$input = Read-Host
|
|
if ($input -eq "y") {
|
|
Clear-RecycleBin -Force
|
|
Restart-Computer -Force
|
|
}
|
|
}
|
|
|
|
function CustomSetup {
|
|
$Office = 0
|
|
$Activate
|
|
$Users = 0
|
|
$UserReg = 0
|
|
$UserRegUsername = ""
|
|
$RDP = 0
|
|
$Choco = 0
|
|
$ChocoApps = 0
|
|
$Update = 0
|
|
$WDAC = 0
|
|
|
|
$input = Read-Host "Do you need to install Office? (y/n)"
|
|
if ($input -eq "y") { $Office = 1 }
|
|
|
|
$input = Read-Host "Do you need to activate Windows and Office? (y/n)"
|
|
if ($input -eq "y") { $Activate = 1 }
|
|
|
|
$input = Read-Host "Do you need to setup users? (y/n)"
|
|
if ($input -eq "y") {
|
|
$Users = 1
|
|
$input = Read-Host "Do you need to setup a restricted user registry? (y/n)"
|
|
if ($input -eq "y") {
|
|
$UserReg = 1
|
|
$input = Read-Host "Enter the username of the user you want to setup"
|
|
$UserRegUsername = $input
|
|
}
|
|
}
|
|
|
|
$input = Read-Host "Do you need to enable RDP? (y/n)"
|
|
if ($input -eq "y") { $RDP = 1 }
|
|
|
|
$input = Read-Host "Do you need to install chocolatey? (y/n)"
|
|
if ($input -eq "y") {
|
|
$Choco = 1
|
|
$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 = 1 }
|
|
|
|
$input = Read-Host "Do you need to setup WDAC? (y/n)"
|
|
if ($input -eq "y") { $WDAC = 1 }
|
|
SetupCustom -Office $Office -Activate $Activate -Users $Users -UserReg $UserReg -UserRegUsername $UserRegUsername -RDP $RDP -Choco $Choco -ChocoApps $ChocoApps -Update $Update -WDAC $WDAC
|
|
}
|
|
|
|
function SetupCustom {
|
|
param (
|
|
[bool] $Office,
|
|
[bool] $Activate,
|
|
[bool] $Users,
|
|
[bool] $UserReg,
|
|
[string] $UserRegUsername,
|
|
[bool] $RDP,
|
|
[bool] $Choco,
|
|
[array] $ChocoApps,
|
|
[bool] $Update,
|
|
[bool] $WDAC
|
|
)
|
|
Write-Host "Performing Custom Installation..."
|
|
if ($Office) { SetupOffice }
|
|
if ($Activate) { SetupActivaton }
|
|
if ($Users) {
|
|
SetupUsers
|
|
if ($UserReg) { SetupUserReg -username $UserRegUsername }
|
|
}
|
|
if ($RDP) { EnableRDP }
|
|
if ($Choco) {
|
|
InstallChoco
|
|
if ($ChocoApps) { ChocoInstallApps -Type "Custom" -Apps $ChocoApps }
|
|
}
|
|
if ($Update) { UpdateWindows }
|
|
if ($WDAC) { SetupWDAC -enable $WDAC }
|
|
Write-Host "Would you like to restart now? (y/n)"
|
|
$input = Read-Host
|
|
if ($input -eq "y") {
|
|
Clear-RecycleBin
|
|
Restart-Computer -Force
|
|
}
|
|
}
|
|
|
|
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"
|
|
Write-Host "4. Custom"
|
|
Write-Host "q. Exit"
|
|
|
|
$selection = Read-Host "Enter the number of your choice"
|
|
|
|
switch ($selection) {
|
|
"1" { StandardSetup -Type "Labo" }
|
|
"2" { StandardSetup -Type "Info" }
|
|
"3" { StandardSetup -Type "Laptop" }
|
|
"4" { CustomSetup }
|
|
"q" {
|
|
Write-Host "Exiting..."
|
|
exit
|
|
}
|
|
default { Write-Host "Invalid selection." }
|
|
}
|
|
} while ($selection -ne "1" -and $selection -ne "2" -and $selection -ne "3" -and $selection -ne "4" -and $selection -ne "q")
|
|
}
|
|
|
|
if (Test-Path -Path "C:\Windows\System32\CodeIntegrity\CiPolicies\Active\{b4d6b24c-c3ad-44e5-9dea-72c1ed9577b8}.cip") {
|
|
Write-Host "WDAC is enabled, should we disabled it? (y/n)"
|
|
Write-Host "Not disabling WDAC will prevent the script from running properly. You should enable it again after the script is done."
|
|
$input = Read-Host
|
|
if ($input -eq "y") {
|
|
Remove-Item -Path "C:\Windows\System32\CodeIntegrity\CiPolicies\Active\{b4d6b24c-c3ad-44e5-9dea-72c1ed9577b8}.cip"
|
|
}
|
|
}
|
|
ImportModules
|
|
Show-InstallationMenu |