PortValhalla/scripts/Windows/OS/Install.ps1

713 lines
33 KiB
PowerShell
Raw Normal View History

2023-07-12 20:37:31 +00:00
#!/bin/pwsh
using namespace System.Management.Automation.Host;
2024-08-09 02:19:49 +00:00
using namespace System.Security.Principal;
. "$PSScriptRoot/../Scripts/Prerequisites.ps1";
2023-06-16 18:24:22 +00:00
. "$PSScriptRoot/Manage.ps1";
2024-03-23 14:38:06 +00:00
. "$PSScriptRoot/User/Install.ps1";
. "$PSScriptRoot/../Scripts/Security.ps1";
. "$PSScriptRoot/../Software/Firefox/Install.ps1";
2024-08-07 19:05:32 +00:00
. "$PSScriptRoot/../../Common/Scripts/Context.ps1";
2024-08-09 22:23:37 +00:00
. "$PSScriptRoot/../../Common/Types/OneShotTask.ps1";
2023-06-16 18:24:22 +00:00
$null = New-Module {
2024-08-01 19:49:46 +00:00
. "$PSScriptRoot/../Scripts/Hooks.ps1";
. "$PSScriptRoot/../Scripts/PowerManagement.ps1";
2024-08-09 02:19:49 +00:00
. "$PSScriptRoot/../Scripts/Registry.ps1";
2024-08-09 14:02:33 +00:00
. "$PSScriptRoot/../Scripts/Security.ps1";
2024-08-01 19:49:46 +00:00
. "$PSScriptRoot/../Scripts/Update.ps1";
2024-08-08 15:49:43 +00:00
. "$PSScriptRoot/../Scripts/Users.ps1";
2024-08-07 19:05:32 +00:00
. "$PSScriptRoot/../../Common/Scripts/Config.ps1";
. "$PSScriptRoot/../../Common/Scripts/Operations.ps1";
. "$PSScriptRoot/../../Common/Scripts/Software.ps1";
. "$PSScriptRoot/../../Common/Scripts/SoftwareManagement.ps1";
. "$PSScriptRoot/../../Common/Types/InstallerAction.ps1";
2024-08-09 22:23:37 +00:00
. "$PSScriptRoot/../../Common/Types/OneShotTask.ps1";
<#
.SYNOPSIS
Finishes the installation of a running Windows machine.
#>
function Start-WindowsInstallation {
Start-Operation {
Start-InstallationLoop;
};
}
2024-07-31 14:15:09 +00:00
<#
.SYNOPSIS
Starts the installation loop.
#>
function Start-InstallationLoop {
2024-08-09 14:02:33 +00:00
$wslLocation = "$env:ProgramData\PortValhalla\Ubuntu";
while (-not (Get-IsFinished)) {
switch (Get-Stage) {
($null) {
Set-Stage ([SetupStage]::Initialize);
break;
2024-08-08 03:14:31 +00:00
}
([SetupStage]::Initialize) {
if (-not ((Test-Command "choco") -and (Test-Command "refreshenv"))) {
Invoke-Hook "Install-Chocolatey" -Fallback {
# Install chocolatey
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'));
Import-Module $env:ChocolateyInstall/helpers/chocolateyProfile.psm1;
refreshenv;
};
continue;
}
2024-08-08 03:14:31 +00:00
if (-not (Test-Command "gsudo")) {
Install-ChocoPackage gsudo;
refreshenv;
continue;
}
2024-08-01 00:59:32 +00:00
if (-not (Test-Command "git")) {
Install-ChocoPackage git;
refreshenv;
continue;
}
2024-08-01 12:06:40 +00:00
if (-not (Test-ChocoPackage "powershell-core")) {
Invoke-Hook "Install-PowerShellCore" -Fallback {
choco install -y powershell-core --install-arguments='"ADD_FILE_CONTEXT_MENU_RUNPOWERSHELL=1 ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1 REGISTER_MANIFEST=1 USER_MU=1 ENABLE_MU=1"';
};
if ($env:DEBUG) {
if (
(Test-Qemu) -and
($Host.UI.PromptForChoice(
"Confirm",
"Do you wish to swap to live scripts?",
[ChoiceDescription[]]@(
[ChoiceDescription]::new("&No", "Use scripts stored in the virtual machine"),
[ChoiceDescription]::new("&Yes", "Use live scripts stored on the host")),
0) -eq 1)) {
Install-ChocoPackage winfsp qemu-guest-agent;
Get-Service VirtioFsSvc | Start-Service -PassThru | Set-Service -StartupType Automatic;
while (-not (Test-Path Z:\)) {
Start-Sleep 0.1;
}
foreach ($name in @("CONFIG_MODULE", "INSTALLER_SCRIPT")) {
$variable = Get-Item "Env:\$name";
$path = Join-Path `
"Z:\Repositories\PortValhalla" `
([System.IO.Path]::GetRelativePath("$PSScriptRoot/../../..", $variable.Value));
Set-Item "Env:\$name" $path;
Write-Host "The new value of ``$name`` is ``$path``";
}
}
}
Restart-Intermediate;
return;
}
2024-08-01 00:59:32 +00:00
if ($env:PWSH_PATH -and (Test-Path $env:PWSH_PATH)) {
attrib "-R" "$env:PWSH_PATH\*" /S /D;
Remove-Item -Recurse -Force $env:PWSH_PATH;
continue;
}
2024-08-08 11:17:14 +00:00
if (-not (Test-Winget)) {
. "$PSScriptRoot/../Software/winget/Manage.ps1";
continue;
}
2024-08-08 20:08:13 +00:00
if (-not (& { $null = wsl --status; $?; })) {
wsl --install --no-launch;
Restart-Intermediate;
return;
}
2024-08-01 00:59:32 +00:00
if (-not (& { $null = wsl -l; $?; })) {
2024-08-09 14:02:33 +00:00
$wslRoot = Split-Path -Parent $wslLocation;
2024-08-09 23:50:52 +00:00
if (-not (Test-Path $wslRoot)) {
2024-08-09 14:02:33 +00:00
$null = New-Item -ItemType Directory $wslRoot;
}
Copy-Item -Recurse -Force (Get-AppxPackage "*Ubuntu*").InstallLocation $wslLocation;
Set-UserPermissions $wslLocation;
& "$wslLocation\ubuntu.exe" install --root;
continue;
}
2024-08-08 11:17:14 +00:00
if (-not (wsl --shell-type login type -t nix)) {
wsl -- sh `<`(curl -L https://nixos.org/nix/install`) --daemon --yes;
wsl --shutdown;
continue;
}
2024-08-08 21:03:10 +00:00
if (-not (Test-PSPackage Selenium.WebDriver)) {
Write-Host "Installing browser automation tools…";
Install-Module -AcceptLicense -Force NuGet;
Import-Module NuGet;
$null = Install-Package -Force Selenium.WebDriver -RequiredVersion 4.10.0 -SkipDependencies;
continue;
}
2024-08-08 21:03:10 +00:00
Install-ChocoPackage selenium-gecko-driver firefox;
2024-08-01 00:59:32 +00:00
Invoke-Hook "Install-PSModules" -Fallback {
Install-Module -Scope AllUsers -AcceptLicense -Force PSWindowsUpdate;
Install-Module -Scope AllUsers -AcceptLicense -Force PSScriptAnalyzer;
. "$PSScriptRoot/../Software/PinnedItem/Manage.ps1";
};
2024-08-01 14:32:03 +00:00
2024-08-16 13:22:09 +00:00
Install-WingetPackage AutoHotkey.AutoHotkey;
Set-Stage ([SetupStage]::Configure);
break;
}
2024-08-09 22:23:37 +00:00
([SetupStage]::OneShot) {
Write-Host "Running a OneShot task";
Start-OneShot {
Write-Host "task is-a running!";
switch (Get-OneShotTask) {
([OneShotTask]::DisableUAC) {
Disable-UAC;
Register-Setup;
2024-08-09 22:23:37 +00:00
}
}
};
break;
}
default {
2024-08-09 14:02:33 +00:00
if (-not (& { $null = wsl -l; $? })) {
wsl --import-in-place "PortValhalla" "$wslLocation/ext4.vhdx";
wsl --set-default "PortValhalla";
}
2024-08-09 14:02:24 +00:00
if (Test-Admin) {
$null = Import-Module PSWindowsUpdate;
2024-08-09 14:02:24 +00:00
Invoke-Hook "Invoke-WindowsUpdate" -Fallback {
Update-WindowsInstallation;
};
2024-08-01 14:32:03 +00:00
2024-08-09 14:02:24 +00:00
if ((Get-WURebootStatus -Silent)) {
Restart-Intermediate;
return;
}
}
<#
.SYNOPSIS
Deploys an action for each software.
.PARAMETER Action
The action to execute by default.
#>
function Deploy-SoftwareAction {
param(
[Nullable[InstallerAction]] $Action = $null
)
[bool] $install = $null;
$arguments = [hashtable]@{ };
2024-08-10 13:15:21 +00:00
if ($null -ne $Action) {
$install = ($Action -eq ([InstallerAction]::Install));
$null = $arguments.Add("action", $Action);
} else {
$install = $true;
}
2024-08-07 14:17:49 +00:00
# Drivers
2024-08-10 13:16:57 +00:00
& {
$driverPath = "$PSScriptRoot/../Drivers";
$mbPath = "$driverPath/ROG Zenith Extreme Alpha";
2024-08-11 16:27:16 +00:00
if ($install) {
if (Get-Config "valhalla.hardware.elgatoWave") {
if (-not (Test-ChocoPackage wavelink)) {
Install-ChocoPackage wavelink -ArgumentList '--install-arguments="/norestart"';
Remove-DesktopIcon "*Wave Link*";
Restart-Intermediate;
exit;
}
}
}
2024-08-11 16:27:16 +00:00
foreach ($component in (Get-Config "valhalla.hardware.components")) {
switch ($component) {
("ROG Zenith Extreme Alpha") {
2024-08-10 13:16:57 +00:00
& "$mbPath/MarvellEthernet/Manage.ps1" @arguments;
& "$mbPath/IntelWiFi/Manage.ps1" @arguments;
& "$mbPath/IntelBluetooth/Manage.ps1" @arguments;
& "$mbPath/AMDChipsetX399/Manage.ps1" @arguments;
& "$driverPath/AMDChipsetX399/Manage.ps1" @arguments;
}
("Predator Z301C") {
2024-08-10 13:16:57 +00:00
& "$driverPath/Predator Z301C/Manage.ps1" @arguments;
}
}
}
2024-08-07 14:17:49 +00:00
if ($install) {
if (Get-Config "valhalla.hardware.amdCPU") {
Install-ChocoPackage amd-ryzen-master;
# ToDo: backup Ryzen energy saving plan
2024-08-07 14:17:49 +00:00
}
if (Get-Config "valhalla.hardware.nvidiaGPU") {
Install-ChocoPackage geforce-game-ready-driver;
Remove-DesktopIcon "*Geforce*";
}
if (Get-Config "valhalla.hardware.corsairDevice") {
Install-ChocoPackage icue;
2024-08-07 14:17:49 +00:00
}
2024-08-07 16:54:07 +00:00
}
2024-08-07 14:17:49 +00:00
if (Get-Config "valhalla.hardware.eyeX") {
2024-08-10 13:16:57 +00:00
& "$driverPath/Tobii EyeX/Manage.ps1" @arguments;
2024-08-07 16:54:07 +00:00
}
};
2024-08-10 13:16:57 +00:00
& {
# Windows Config
$softwarePath = "$PSScriptRoot/../Software";
$commonSoftware = "$PSScriptRoot/../../Common/Software";
2024-08-10 13:16:57 +00:00
& "$softwarePath/Windows/Manage.ps1" @arguments;
2024-08-07 14:17:49 +00:00
if (Get-Config "valhalla.hardware.logitechG") {
2024-08-10 13:16:57 +00:00
& "$softwarePath/LGHub/Manage.ps1" @arguments;
2024-08-07 16:54:07 +00:00
}
2024-08-07 14:17:49 +00:00
if (Test-Collection "essential") {
# Essentials
2024-08-10 13:16:57 +00:00
& "$softwarePath/OpenSSH/Manage.ps1" @arguments;
& "$softwarePath/PowerShell/Manage.ps1" @arguments;
& "$softwarePath/chocolatey/Manage.ps1" @arguments;
& "$softwarePath/zoxide/Manage.ps1" @arguments;
& "$commonSoftware/posh-git/Manage.ps1" @arguments;
& "$commonSoftware/Terminal-Icons/Manage.ps1" @arguments;
2024-08-10 18:37:10 +00:00
& "$softwarePath/Oh My Posh/Manage.ps1" @arguments;
if ($install) {
Install-ChocoPackage `
procexp `
procmon `
;
Install-WingetPackage `
KDE.KDEConnect `
;
2024-08-07 16:54:07 +00:00
}
}
2024-08-07 14:17:49 +00:00
if (Test-Collection "common") {
# Common Software
2024-08-10 13:16:57 +00:00
& "$softwarePath/WinSCP/Manage.ps1" @arguments;
& "$softwarePath/Thunderbird/Manage.ps1" @arguments;
& "$softwarePath/PuTTY/Manage.ps1" @arguments;
if ($install) {
Install-ChocoPackage `
7zip `
chocolateygui `
DefaultProgramsEditor `
bitwarden `
keepass `
;
Install-WingetPackage `
SomePythonThings.WingetUIStore `
;
}
}
2024-08-07 14:17:49 +00:00
if (Test-Collection "desktopExperience") {
if ($install) {
# Fonts
Install-ChocoPackage nerd-fonts-CascadiaCode;
# Internet Access
Install-WingetPackage Brave.Brave kamranahmedse.pennywise;
Remove-DesktopIcon "*Brave*";
Remove-TaskbarItem "*Brave*";
Remove-DesktopIcon "Pennywise*";
# Tools
Install-SetupPackage -Source "https://github.com/mRemoteNG/mRemoteNG/releases/download/2023.03.03-v1.77.3-nb/mRemoteNG-Installer-1.77.3.nb-1784.msi" -ArgumentList "/Quiet";
Remove-DesktopIcon "mRemoteNG*";
Install-ChocoPackage `
gimp `
gpu-z `
windirstat `
winmerge `
handbrake `
hwmonitor `
qbittorrent `
imgburn `
inkscape `
krita `
MetaX `
obs-studio `
;
Remove-DesktopIcon "GPU-Z*";
Remove-DesktopIcon "WinDirStat*";
Remove-DesktopIcon "*HWMonitor*";
Remove-DesktopIcon "ImgBurn*";
Remove-DesktopIcon "InkScape*";
Remove-DesktopIcon "Krita*";
Remove-DesktopIcon "MetaX*";
Remove-DesktopIcon "OBS Studio*";
Install-WingetPackage `
AntSoftware.AntRenamer `
AppWork.JDownloader;
Remove-DesktopIcon "JDownloader*";
}
# ToDo: Consider hiding behind own config?
2024-08-10 13:16:57 +00:00
& "$softwarePath/Ubiquiti UniFi Controller/Manage.ps1" @arguments;
2024-08-08 02:36:35 +00:00
# Internet Access
2024-08-10 13:16:57 +00:00
& "$softwarePath/Firefox/Manage.ps1" @arguments;
& "$softwarePath/MSEdgeRedirect/Manage.ps1" @arguments;
2024-08-08 02:36:35 +00:00
if (Test-Collection "fileSync") {
2024-08-10 13:16:57 +00:00
& "$softwarePath/Nextcloud/Manage.ps1" @arguments;
}
2024-08-08 02:36:35 +00:00
}
2024-08-07 16:30:14 +00:00
if (Test-Collection "socialMedia") {
if ($install) {
Install-ChocoPackage `
signal `
threema-desktop `
element-desktop `
teamspeak `
;
2024-08-08 02:36:35 +00:00
Remove-DesktopIcon "*Element*";
Remove-DesktopIcon "*TeamSpeak*";
2024-08-07 21:53:12 +00:00
Install-WingetPackage Discord.Discord;
Remove-DesktopIcon "*Discord*";
}
2024-08-08 02:36:35 +00:00
}
if (Test-Collection "media") {
if ($install) {
Install-ChocoPackage `
k-litecodecpackmega `
vlc `
;
Remove-DesktopIcon "VLC*";
2024-08-15 00:22:07 +00:00
Install-ChocoPackage jellyfin-media-player -ArgumentList "--install-args","/norestart"
Install-WingetPackage Ytmdesktop.Ytmdesktop;
Remove-DesktopIcon "Youtube Music*";
}
}
2024-08-08 02:36:35 +00:00
if (Test-Collection "coding") {
if ($install) {
Install-ChocoPackage vscode -ArgumentList "--params","/NoDesktopIcon";
Install-ChocoPackage vscodium -ArgumentList "--params","/NoDesktopIcon /AssociateWithFiles";
Install-ChocoPackage `
gh `
github-desktop `
ida-free `
HxD `
docker-desktop `
imhex `
dotpeek `
;
Remove-DesktopIcon "IDA *";
Remove-DesktopIcon "GitHub*";
Remove-DesktopIcon "Docker*";
}
2024-08-07 21:53:12 +00:00
2024-08-10 13:16:57 +00:00
& "$softwarePath/VisualStudio/Manage.ps1" @arguments;
2024-08-08 02:36:35 +00:00
# Node.js
2024-08-10 13:16:57 +00:00
& "$softwarePath/NVS/Manage.ps1" @arguments;
2024-08-08 02:36:35 +00:00
}
if (Test-Collection "gaming") {
# Gaming
if ($install) {
Install-ChocoPackage `
goggalaxy `
epicgameslauncher `
rayman-controlpanel `
ppsspp `
;
Remove-DesktopIcon "*Epic Games*";
Remove-DesktopIcon "*PPSSPP *-Bit*";
2024-08-14 16:46:42 +00:00
Install-ChocoPackage `
steam `
ubisoft-connect `
-ArgumentList "--ignore-checksums" `
;
Remove-DesktopIcon "*Steam*";
Remove-DesktopIcon "*Ubisoft Connect*";
Install-WingetPackage ElectronicArts.EADesktop;
Remove-DesktopIcon "EA.*";
}
2024-08-08 02:36:35 +00:00
2024-08-10 13:16:57 +00:00
& "$softwarePath/TrackMania Nations Forever/Manage.ps1" @arguments;
& "$softwarePath/TrackMania United Forever/Manage.ps1" @arguments;
& "$softwarePath/ManiaPlanet/Manage.ps1" @arguments;
& "$softwarePath/osu!/Manage.ps1" @arguments;
& "$softwarePath/osu!lazer/Manage.ps1" @arguments;
& "$softwarePath/RetroArch/Manage.ps1" @arguments;
& "$softwarePath/reWASD/Manage.ps1" @arguments;
2024-08-08 02:36:35 +00:00
}
};
}
2024-08-08 02:36:35 +00:00
switch (Get-Stage) {
([SetupStage]::Configure) {
if (Get-Config "valhalla.windows.dualboot.enable") {
# Fix synchronization between Linux and Windows clocks.
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\TimeZoneInformation" -Name "RealTimeIsUniversal" -Value 1 -Type "DWord";
2024-08-08 02:36:35 +00:00
# Force time resynchronization
2024-08-10 13:17:21 +00:00
$timeZoneOption = "Start";
$timeZoneKey = "HKLM:\SYSTEM\CurrentControlSet\Services\tzautoupdate";
$service = Get-Service W32Time;
2024-08-10 17:26:53 +00:00
$autoUpdate = (Get-Item $timeZoneKey).GetValue($timeZoneOption);
$stopped = ($service.Status -eq "Stopped");
2024-08-10 13:17:21 +00:00
$setUpdate = { param([int] $Value) Set-ItemProperty $timeZoneKey -Name $timeZoneOption $Value };
& $setUpdate 3;
Start-Service $service;
w32tm /resync /force;
2024-08-10 13:17:21 +00:00
& $setUpdate $autoUpdate;
2024-08-08 02:36:35 +00:00
if ($stopped) {
Stop-Service $service;
}
2024-08-08 02:36:35 +00:00
}
Set-Stage ([SetupStage]::Install);
2024-08-08 02:36:35 +00:00
}
([SetupStage]::Install) {
Write-Host "Entering install phase";
Deploy-SoftwareAction;
Set-Stage ([SetupStage]::CreateUser);
2024-08-01 14:32:03 +00:00
}
([SetupStage]::CreateUser) {
Start-ValhallaUserSetup;
Set-Stage ([SetupStage]::ConfigureUser);
}
([SetupStage]::ConfigureUser) {
$userOption = "CurrentUser";
2024-08-01 23:44:56 +00:00
function Get-CurrentUser {
(Get-SetupOption $userOption) ?? 0;
}
2024-08-09 02:19:49 +00:00
function Set-CurrentUser {
param([int] $Value)
Set-SetupOption $userOption $Value;
}
2024-08-09 02:19:49 +00:00
[string[]] $users = Get-Users;
$currentUser = Get-CurrentUser;
2024-08-09 14:02:00 +00:00
if (Test-Admin) {
Disable-BootMessage;
}
2024-08-09 02:19:49 +00:00
if ($currentUser -lt $users.Count) {
$user = Get-LocalUser $users[$currentUser];
$msAccount = Get-UserConfig -UserName "$user" -Name "microsoftAccount";
2024-08-09 02:19:49 +00:00
2024-08-10 13:21:13 +00:00
$adminGroup = @{
SID = [SecurityIdentifier]::new([WellKnownSidType]::BuiltinAdministratorsSid, $null);
};
Add-LocalGroupMember `
2024-08-10 13:21:13 +00:00
@adminGroup `
$user `
-ErrorAction SilentlyContinue;
2024-08-09 02:19:49 +00:00
if ($env:UserName -ne "$user") {
Disable-LocalUser $env:UserName;
Enable-LocalUser $user;
2024-08-09 02:19:49 +00:00
if ($msAccount) {
Enable-UAC;
Disable-Autologin;
Enable-OneShotListener;
2024-08-09 20:11:12 +00:00
Set-BootMessage -Caption "Please Log In" -Message "Please log in using your new Microsoft Account ``$user``.";
} else {
Set-AutologinUser "$user";
}
2024-08-09 02:19:49 +00:00
Restart-Intermediate -DefaultUser;
return;
} else {
2024-08-10 13:21:13 +00:00
$configure = {
Deploy-SoftwareAction -Action ([InstallerAction]::ConfigureUser);
Remove-LocalGroupMember -Member "$user" @adminGroup -ErrorAction SilentlyContinue;
2024-08-10 13:23:38 +00:00
foreach ($group in Get-UserConfig -UserName "$user" "groups") {
Add-LocalGroupMember -Member "$user" -Name "$group";
}
2024-08-10 13:21:13 +00:00
}
if ($msAccount) {
if (-not (Test-Admin)) {
Invoke-OneShot DisableUAC;
Restart-Computer;
return;
2024-08-10 13:21:13 +00:00
} else {
& $configure;
Clear-SetupRegistration;
Disable-OneShotListener;
}
2024-08-10 13:21:13 +00:00
} else {
& $configure;
}
2024-08-09 02:19:49 +00:00
}
if (-not $msAccount) {
net user "$user" /logonpasswordchg:yes;
}
Set-CurrentUser ($currentUser + 1);
continue;
2024-08-09 02:19:49 +00:00
}
Set-IsFinished $true;
2024-08-09 02:19:49 +00:00
}
}
2024-08-01 14:32:03 +00:00
}
}
}
}
function Invoke-WindowsInstallation([Context] $context) {
$Global:InformationPreference = "Continue";
$Global:ErrorActionPreference = "Inquire";
$context.UserNames ??= @("Manuel");
Start-OldWindowsInstallationScript $context;
}
function Start-OldWindowsInstallationScript([Context] $context) {
. "$PSScriptRoot/Upgrade.ps1";
$finished = $false;
Remove-Item Env:\POSH_THEME -ErrorAction SilentlyContinue;
$configPath = "$PSScriptRoot/../Config";
$softwarePath = "$PSScriptRoot/../Software";
$initialConfigStage = "InitialConfiguration";
$prerequisitesStage = "InstallationPrerequisites";
$driverStage = "DriverInstallation";
$softwareStage = "MachineWideSoftwareInstallation";
$userStage = "CreatingUser";
$restorationStage = "Restoring";
while (-not $finished) {
switch ($context.GetStage()) {
{ (-not $_) -or ($_ -eq $initialConfigStage) } {
$context.SetStage($initialConfigStage);
if ((Get-Command Initialize-Configuration -ErrorAction SilentlyContinue)) {
Write-Information "Configuration initialization function was found. Running...";
Initialize-Configuration $context;
}
$null = Enable-WindowsOptionalFeature -Online -All -FeatureName "NetFx3";
. "$configPath/Windows/Install.ps1" $context;
. "$configPath/Explorer/Install.ps1" $context;
. "$configPath/OpenSSH/Install.ps1" $context;
. "$configPath/chocolatey/Install.ps1";
$context.RemoveDesktopIcon("*Microsoft Edge*");
$context.SetStage($prerequisitesStage);
break;
}
# Always install updates
default {
Write-Host "Starting Installation and Restoration of Windows";
Update-WindowsInstallation $context;
}
$prerequisitesStage {
Write-Host "Installing prerequisites for installing software";
if (-not $(Get-Command winget)) {
choco install -y winget;
}
Install-Module -AcceptLicense -Force "NuGet";
Import-Module NuGet;
Install-Firefox $context;
choco install -y selenium-gecko-driver;
$null = Install-Package -Force Selenium.WebDriver -RequiredVersion 4.10.0 -SkipDependencies;
winget install --accept-source-agreements --accept-package-agreements -e --id AutoHotkey.AutoHotkey;
$context.SetStage($driverStage);
break;
}
$driverStage {
Write-Host "Installing drivers";
if ((Get-Command Install-PortValhallaDrivers -ErrorAction SilentlyContinue)) {
Write-Information "Driver installation function was found. Starting installation";
Install-PortValhallaDrivers $context;
}
Write-Information "Finished installing drivers";
$context.SetStage($softwareStage);
$context.Reboot();
exit;
}
$softwareStage {
Write-Host "Setting up software with default app associations";
. "$softwarePath/WinSCP/Install.ps1" $context;
. "$softwarePath/Thunderbird/Install.ps1" $context;
Write-Host "Installing default settings for new users";
. "$softwarePath/aliae/Install.ps1" $context;
. "$softwarePath/posh-git/Install.ps1";
. "$softwarePath/Terminal-Icons/Install.ps1";
. "$softwarePath/Oh My Posh/Install.ps1" $context;
$context.SetStage($userStage);
break;
}
$userStage {
Install-PersonalUsers $context;
$context.SetStage($restorationStage);
break;
}
$restorationStage {
Restore-WindowsInstallation $context;
$finished = $true;
break;
}
}
2023-08-13 23:32:57 +00:00
}
2023-07-16 10:56:54 +00:00
}
};