Initial commit: Living Room PC setup scripts
This commit is contained in:
parent
9c1e897bdc
commit
fe187a5b92
17 changed files with 466 additions and 36 deletions
214
install.ps1
214
install.ps1
|
|
@ -1,9 +1,111 @@
|
|||
# This script will install the components to make a Living Room PC
|
||||
# Main focus is for gaming, primarily on Steam
|
||||
|
||||
# Apps to be installed:
|
||||
# - Steam (winget: Valve.Steam, choco: steam)
|
||||
# - PowerShell 7 (winget: Microsoft.PowerShell, choco: powershell-core)
|
||||
# - BGInfo (winget: Sysinternals.BGInfo, choco: bginfo)
|
||||
# - VCRedist (winget: Microsoft.VCRedist.2015+.x64, choco: vcredist140)
|
||||
# - btop4win (winget: not available, choco: btop4win)
|
||||
# - Microsoft Edit (winget: Microsoft.Edit, choco: not available)
|
||||
|
||||
# Requires running as administrator
|
||||
#Requires -RunAsAdministrator
|
||||
|
||||
### Package Manager Setup ###
|
||||
Write-Host "Setting up package managers..." -ForegroundColor Green
|
||||
|
||||
# Check and setup Winget
|
||||
Write-Host "Checking Winget..." -ForegroundColor Yellow
|
||||
$wingetPath = Get-Command winget -ErrorAction SilentlyContinue
|
||||
|
||||
if (-not $wingetPath) {
|
||||
Write-Host "Winget is not installed. Installing via Microsoft Store..." -ForegroundColor Yellow
|
||||
Start-Process "ms-windows-store://pdp/?ProductId=9NBLGGH4NNS1"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check Winget version
|
||||
$wingetVersion = (winget --version)
|
||||
Write-Host "Current Winget version: $wingetVersion" -ForegroundColor Green
|
||||
|
||||
# Update Winget
|
||||
Write-Host "Updating Winget..." -ForegroundColor Yellow
|
||||
winget upgrade --all --include-unknown
|
||||
|
||||
# Setup Chocolatey
|
||||
Write-Host "Setting up Chocolatey..." -ForegroundColor Yellow
|
||||
|
||||
# Set TLS 1.2 for security
|
||||
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
|
||||
|
||||
# Check if Chocolatey is already installed
|
||||
if (-not (Get-Command choco -ErrorAction SilentlyContinue)) {
|
||||
Write-Host "Installing Chocolatey..." -ForegroundColor Yellow
|
||||
|
||||
# Create the installation directory if it doesn't exist
|
||||
$chocoPath = "$env:ProgramData\chocolatey"
|
||||
if (-not (Test-Path $chocoPath)) {
|
||||
New-Item -ItemType Directory -Path $chocoPath -Force | Out-Null
|
||||
}
|
||||
|
||||
# Download and run the Chocolatey installation script
|
||||
$installScript = "https://community.chocolatey.org/install.ps1"
|
||||
$tempFile = [System.IO.Path]::GetTempFileName()
|
||||
|
||||
try {
|
||||
Invoke-WebRequest -Uri $installScript -OutFile $tempFile
|
||||
& $tempFile
|
||||
}
|
||||
catch {
|
||||
Write-Error "Failed to install Chocolatey: $_"
|
||||
exit 1
|
||||
}
|
||||
finally {
|
||||
if (Test-Path $tempFile) {
|
||||
Remove-Item $tempFile -Force
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Write-Host "Chocolatey is already installed." -ForegroundColor Green
|
||||
}
|
||||
|
||||
# Verify Chocolatey installation
|
||||
$chocoVersion = (choco --version)
|
||||
Write-Host "Chocolatey version: $chocoVersion" -ForegroundColor Green
|
||||
|
||||
# Update Chocolatey
|
||||
Write-Host "Updating Chocolatey..." -ForegroundColor Yellow
|
||||
choco upgrade chocolatey -y
|
||||
|
||||
### Function to Install Apps ###
|
||||
function Install-App {
|
||||
param (
|
||||
[string]$AppName,
|
||||
[string]$WingetId,
|
||||
[string]$ChocoId,
|
||||
[switch]$UseChocoOnly
|
||||
)
|
||||
|
||||
Write-Host "Installing $AppName..." -ForegroundColor Yellow
|
||||
|
||||
if ($UseChocoOnly) {
|
||||
Write-Host "Using Chocolatey for $AppName..." -ForegroundColor Yellow
|
||||
choco install $ChocoId -y
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
Write-Host "Attempting to install $AppName via Winget..." -ForegroundColor Yellow
|
||||
winget install -e --id $WingetId --accept-source-agreements --accept-package-agreements
|
||||
}
|
||||
catch {
|
||||
Write-Host "Winget installation failed, falling back to Chocolatey..." -ForegroundColor Yellow
|
||||
choco install $ChocoId -y
|
||||
}
|
||||
}
|
||||
|
||||
### Remove Bloatware
|
||||
Write-Host "Starting debloating process..." -ForegroundColor Green
|
||||
|
||||
|
|
@ -26,7 +128,7 @@ Remove-Item -Path "$env:SYSTEMDRIVE\OneDriveTemp" -Force -Recurse -ErrorAction S
|
|||
|
||||
# Install PowerShell 7 and set as default
|
||||
Write-Host "Installing PowerShell 7..." -ForegroundColor Yellow
|
||||
winget install -e --id Microsoft.PowerShell --accept-source-agreements --accept-package-agreements
|
||||
Install-App -AppName "PowerShell 7" -WingetId "Microsoft.PowerShell" -ChocoId "powershell-core"
|
||||
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "DontUsePowerShellOnWinX" -Value 0 -Type DWord
|
||||
|
||||
# Debloat Edge
|
||||
|
|
@ -90,42 +192,92 @@ cleanmgr /sagerun:1
|
|||
### Steam
|
||||
# Install Steam using winget
|
||||
Write-Host "Installing Steam..." -ForegroundColor Green
|
||||
winget install -e --id Valve.Steam --accept-source-agreements --accept-package-agreements
|
||||
Install-App -AppName "Steam" -WingetId "Valve.Steam" -ChocoId "steam"
|
||||
|
||||
### BGInfo
|
||||
# Script variables
|
||||
$bgInfoPath = "$env:USERPROFILE\.bginfo"
|
||||
### Install Required Components
|
||||
Write-Host "Installing required components..." -ForegroundColor Green
|
||||
|
||||
# Function to ensure a directory exists
|
||||
function EnsureDirectory {
|
||||
param([string]$path)
|
||||
if (-not (Test-Path $path)) {
|
||||
New-Item -ItemType Directory -Path $path -Force | Out-Null
|
||||
}
|
||||
# Install VCRedist
|
||||
Install-App -AppName "Visual C++ Redistributable" -WingetId "Microsoft.VCRedist.2015+.x64" -ChocoId "vcredist140"
|
||||
|
||||
# Install OpenSSH using PowerShell method
|
||||
Write-Host "Installing OpenSSH..." -ForegroundColor Yellow
|
||||
|
||||
# Check if OpenSSH is available
|
||||
$sshCapabilities = Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
|
||||
Write-Host "Available OpenSSH capabilities:" -ForegroundColor Yellow
|
||||
$sshCapabilities | Format-Table Name, State
|
||||
|
||||
# Install OpenSSH Client and Server
|
||||
Write-Host "Installing OpenSSH components..." -ForegroundColor Yellow
|
||||
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
|
||||
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
|
||||
|
||||
# Start and configure OpenSSH Server
|
||||
Write-Host "Configuring OpenSSH Server..." -ForegroundColor Yellow
|
||||
Start-Service sshd
|
||||
Set-Service -Name sshd -StartupType 'Automatic'
|
||||
|
||||
# Configure Windows Firewall for SSH
|
||||
Write-Host "Configuring Windows Firewall for SSH..." -ForegroundColor Yellow
|
||||
if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue | Select-Object Name, Enabled)) {
|
||||
Write-Host "Creating firewall rule for SSH..." -ForegroundColor Yellow
|
||||
New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
|
||||
} else {
|
||||
Write-Host "Firewall rule for SSH already exists." -ForegroundColor Green
|
||||
}
|
||||
|
||||
# Install BGInfo using winget
|
||||
Write-Host "Installing BGInfo..." -ForegroundColor Green
|
||||
winget install -e --id Sysinternals.BGInfo --accept-source-agreements --accept-package-agreements
|
||||
# Install btop4win (Chocolatey only)
|
||||
# Note: btop4win requires Visual C++ Redistributable 2015-2022 (x86) to be installed first
|
||||
Write-Host "Installing Visual C++ Redistributable 2015-2022 (x86)..." -ForegroundColor Yellow
|
||||
Install-App -AppName "Visual C++ Redistributable 2015-2022 (x86)" -WingetId "Microsoft.VCRedist.2015+.x86" -ChocoId "vcredist140"
|
||||
|
||||
# Create .bginfo directory
|
||||
Write-Host "Installing btop4win..." -ForegroundColor Yellow
|
||||
Install-App -AppName "btop4win" -ChocoId "btop4win" -UseChocoOnly
|
||||
|
||||
# Install Microsoft Edit
|
||||
Install-App -AppName "Microsoft Edit" -WingetId "Microsoft.Edit" -ChocoId ""
|
||||
|
||||
### Function to Setup BGInfo ###
|
||||
function Setup-BGInfo {
|
||||
param (
|
||||
[string]$ConfigPath = "$env:USERPROFILE\.bginfo\config.bgi"
|
||||
)
|
||||
|
||||
Write-Host "Setting up BGInfo..." -ForegroundColor Yellow
|
||||
|
||||
# Create BGInfo directory
|
||||
$bginfoPath = "$env:USERPROFILE\.bginfo"
|
||||
if (-not (Test-Path $bginfoPath)) {
|
||||
New-Item -ItemType Directory -Path $bginfoPath -Force | Out-Null
|
||||
}
|
||||
|
||||
# Install BGInfo using winget
|
||||
Install-App -AppName "BGInfo" -WingetId "Sysinternals.BGInfo" -ChocoId "bginfo"
|
||||
|
||||
# Copy BGInfo scripts
|
||||
Write-Host "Copying BGInfo scripts..." -ForegroundColor Yellow
|
||||
$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
Copy-Item "$scriptPath\bginfo\*" $bginfoPath -Force
|
||||
|
||||
# Create scheduled task to run BGInfo at logon
|
||||
$bgInfoExe = "$env:ProgramFiles\sysinternals\bginfo.exe"
|
||||
$action = New-ScheduledTaskAction -Execute $bgInfoExe -Argument "$ConfigPath /timer:0"
|
||||
$trigger = New-ScheduledTaskTrigger -AtLogOn
|
||||
$principal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -RunLevel Highest
|
||||
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
|
||||
|
||||
Write-Host "Creating BGInfo startup task..." -ForegroundColor Yellow
|
||||
Register-ScheduledTask -TaskName "BGInfo" -Action $action -Trigger $trigger -Principal $principal -Settings $settings -Force
|
||||
|
||||
# Run BGInfo immediately
|
||||
Write-Host "Running BGInfo..." -ForegroundColor Yellow
|
||||
Start-Process $bgInfoExe -ArgumentList "$ConfigPath /timer:0" -NoNewWindow -Wait
|
||||
}
|
||||
|
||||
### BGInfo Setup ###
|
||||
Write-Host "Setting up BGInfo..." -ForegroundColor Green
|
||||
EnsureDirectory $bgInfoPath
|
||||
|
||||
# Copy BGInfo scripts
|
||||
Write-Host "Copying BGInfo scripts..." -ForegroundColor Yellow
|
||||
$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
Copy-Item "$scriptPath\bginfo\*" $bgInfoPath -Force
|
||||
|
||||
# Create scheduled task to run BGInfo at logon
|
||||
$bgInfoExe = "$env:ProgramFiles\sysinternals\bginfo.exe"
|
||||
$action = New-ScheduledTaskAction -Execute $bgInfoExe -Argument "$bgInfoPath\config.bgi /timer:0"
|
||||
$trigger = New-ScheduledTaskTrigger -AtLogOn
|
||||
$principal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -RunLevel Highest
|
||||
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
|
||||
|
||||
Write-Host "Creating BGInfo startup task..." -ForegroundColor Yellow
|
||||
Register-ScheduledTask -TaskName "BGInfo" -Action $action -Trigger $trigger -Principal $principal -Settings $settings -Force
|
||||
Setup-BGInfo
|
||||
|
||||
### Auto-Login Setup ###
|
||||
Write-Host "Configuring Auto-Login..." -ForegroundColor Green
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue