PortValhalla/scripts/Windows/OS/Install.ps1

59 lines
2 KiB
PowerShell

#!/bin/pwsh
. "$PSScriptRoot/Manage.ps1";
. "$PSScriptRoot/Upgrade.ps1";
. "$PSScriptRoot/User.ps1";
. "$PSScriptRoot/../Scripts/Context.ps1";
. "$PSScriptRoot/../Software/Firefox/Install.ps1";
function Invoke-WindowsInstallation([Context] $context)
{
Write-Host "Starting Installation and Restoration of Windows";
. "$PSScriptRoot/../Scripts/Prerequisites.ps1";
Update-WindowsInstallation $context;
if (-not $context.Get("InitialConfiguration")) {
$configPath = "$PSScriptRoot/../Config";
Enable-WindowsOptionalFeature -Online -All -FeatureName "NetFx3";
. "$configPath/Windows/Install.ps1" $context;
. "$configPath/Explorer/Install.ps1" $context;
. "$configPath/OpenSSH/Install.ps1" $context;
$context.RemoveDesktopIcon("*Microsoft Edge*");
$context.Set("InitialConfiguration", 1, "DWord");
}
if (-not $context.Get("SoftwarePrerequisitesInstalled")) {
Write-Host "Installing prerequisites for installing software";
Install-Module -AcceptLicense -Force "NuGet";
Import-Module NuGet;
Install-Firefox $context;
choco install -y selenium-gecko-driver;
Install-Package -Force Selenium.WebDriver -SkipDependencies;
winget install --accept-source-agreements --accept-package-agreements -e --id AutoHotkey.AutoHotkey;
$context.Set("SoftwarePrerequisitesInstalled", 1, "DWord");
}
if (-not $context.Get("DriversInstalled")) {
Write-Host "Installing Drivers";
Write-Information "Looking for driver installation function";
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.Set("DriversInstalled", 1, "DWord");
$context.Reboot();
exit;
}
New-PersonalUser $context;
Restore-WindowsInstallation $context;
}