Reorganisation of the setup
- Autounattend files moved to Autounattend folder - WDAC files moved to WDAC folder - Added WDAC check to setupScript - Moved RDP to setupRDP - Moved Activate to setupActivate - Added online setup of Office with offline fallback - Changed setupUsers to be more standard and allow customisation - Added rastop setup
This commit is contained in:
149
setupScript.ps1
149
setupScript.ps1
@@ -1,51 +1,55 @@
|
||||
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 + "setupActivate.ps1"),
|
||||
($baseUrl + "setupUsers.ps1"),
|
||||
($baseUrl + "setupReg.ps1"),
|
||||
($baseUrl + "setupRDP.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 OldImport {
|
||||
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 Import {
|
||||
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 Setup {
|
||||
function StandardSetup {
|
||||
param (
|
||||
[string] $Type
|
||||
)
|
||||
Write-Host "Performing $Type Installation..."
|
||||
DownloadFiles -Type $Type
|
||||
CheckOfficeInstall
|
||||
SetupUsers
|
||||
SetupEleveReg -username "Eleve"
|
||||
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
|
||||
@@ -56,96 +60,91 @@ function Setup {
|
||||
Write-Host "Would you like to restart now? (y/n)"
|
||||
$input = Read-Host
|
||||
if ($input -eq "y") {
|
||||
Clear-RecycleBin
|
||||
Clear-RecycleBin -Force
|
||||
Restart-Computer -Force
|
||||
}
|
||||
}
|
||||
|
||||
function Custom {
|
||||
function CustomSetup {
|
||||
$Office = 0
|
||||
$Activate
|
||||
$Users = 0
|
||||
$EleveReg = 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
|
||||
}
|
||||
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 eleve registry? (y/n)"
|
||||
$input = Read-Host "Do you need to setup a restricted user registry? (y/n)"
|
||||
if ($input -eq "y") {
|
||||
$EleveReg = 1
|
||||
$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
|
||||
}
|
||||
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
|
||||
}
|
||||
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
|
||||
}
|
||||
SetupCustom -Office $Office -Users $Users -EleveReg $EleveReg -RDP $RDP -Choco $Choco -ChocoApps $ChocoApps -Update $Update
|
||||
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] $EleveReg,
|
||||
[bool] $UserReg,
|
||||
[string] $UserRegUsername,
|
||||
[bool] $RDP,
|
||||
[bool] $Choco,
|
||||
[array] $ChocoApps,
|
||||
[bool] $Update
|
||||
[bool] $Update,
|
||||
[bool] $WDAC
|
||||
)
|
||||
Write-Host "Performing Custom Installation..."
|
||||
if ($Office) {
|
||||
CheckOfficeInstall
|
||||
}
|
||||
if ($Office) { SetupOffice }
|
||||
if ($Activate) { SetupActivaton }
|
||||
if ($Users) {
|
||||
SetupUsers
|
||||
if ($EleveReg) {
|
||||
SetupEleveReg -username "Eleve"
|
||||
}
|
||||
}
|
||||
if ($RDP) {
|
||||
EnableRDP
|
||||
if ($UserReg) { SetupUserReg -username $UserRegUsername }
|
||||
}
|
||||
if ($RDP) { EnableRDP }
|
||||
if ($Choco) {
|
||||
InstallChoco
|
||||
if ($ChocoApps) {
|
||||
ChocoInstallApps -Type "Custom" -Apps $ChocoApps
|
||||
}
|
||||
if ($ChocoApps) { ChocoInstallApps -Type "Custom" -Apps $ChocoApps }
|
||||
}
|
||||
if ($Update) {
|
||||
UpdateWindows
|
||||
}
|
||||
Show-WDACMenu
|
||||
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") {
|
||||
@@ -168,17 +167,25 @@ function Show-InstallationMenu {
|
||||
$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 }
|
||||
"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")
|
||||
} 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"
|
||||
}
|
||||
}
|
||||
Show-InstallationMenu
|
||||
Reference in New Issue
Block a user