Skip to content

Instantly share code, notes, and snippets.

@hartmantis
Last active August 14, 2021 02:42
Show Gist options
  • Save hartmantis/dcde88512956aa882d49c93ea3621d87 to your computer and use it in GitHub Desktop.
Save hartmantis/dcde88512956aa882d49c93ea3621d87 to your computer and use it in GitHub Desktop.
Windows gaming PC bootstrap script
# There are some steps that can't be done in PowerShell:
#
# Before:
# * Install Windows
# * Run Windows Update and reboot as needed
# * Install WinGet via your desired method (Maybe it's included with AppInstaller by now?)
#
# After:
# * Run the Logitech app and change the touchpad scroll direction
# * Run 1Password and sign in
# * Run Discord and sign in
# * Run GeForce Experience and install real GPU drivers
# * Install Rocksmith to C: drive
# * Copy Rocksmith DLC to C: drive
# List of apps to install:
#
# * Chocolatey (if we still need it)
# * WSL2 + Ubuntu + Alpine(?)
# * Epic Games Launcher (on D: drive?)
# * Origin (if it still exists?) (on D: drive?)
# * GOG Galaxy (on D: drive?)
# * Battle.net (on D: drive?)
function Install-AppxPackage {
[CmdletBinding()]
param (
[string]$Name,
[string]$Uri,
[string]$Path = "$ENV:USERPROFILE\Downloads"
)
process {
$Path = (Resolve-Path "$Path").Path
New-Item -Path "$Path\$Name" -ItemType Directory
$Path = (Resolve-Path "$Path\$Name").Path
#Get Urls to download
$WebResponse = Invoke-WebRequest -UseBasicParsing -Method 'POST' -Uri 'https://store.rg-adguard.net/api/GetFiles' -Body "type=url&url=$Uri&ring=Retail" -ContentType 'application/x-www-form-urlencoded'
$LinksMatch = $WebResponse.Links | where {$_ -like '*.appx*'} | where {$_ -like '*_neutral_*' -or $_ -like "*_"+$env:PROCESSOR_ARCHITECTURE.Replace("AMD","X").Replace("IA","X")+"_*"} | Select-String -Pattern '(?<=a href=").+(?=" r)'
$DownloadLinks = $LinksMatch.matches.value
function Resolve-NameConflict{
#Accepts Path to a FILE and changes it so there are no name conflicts
param(
[string]$Path
)
$newPath = $Path
if(Test-Path $Path){
$i = 0;
$item = (Get-Item $Path)
while(Test-Path $newPath){
$i += 1;
$newPath = Join-Path $item.DirectoryName ($item.BaseName+"($i)"+$item.Extension)
}
}
return $newPath
}
#Download Urls
foreach($url in $DownloadLinks){
$FileRequest = Invoke-WebRequest -Uri $url -UseBasicParsing #-Method Head
$FileName = ($FileRequest.Headers["Content-Disposition"] | Select-String -Pattern '(?<=filename=).+').matches.value
$FilePath = Join-Path $Path $FileName; $FilePath = Resolve-NameConflict($FilePath)
[System.IO.File]::WriteAllBytes($FilePath, $FileRequest.content)
echo $FilePath
}
Get-Childitem $Path -filter *.appx| %{Add-AppxPackage -Path $_.FullName}
Get-Childitem $Path -filter *.appxbundle | %{Add-AppxPackage -Path $_.FullName}
Remove-Item -Recurse -Force $Path
}
}
# Install-AppxPackage "AppInstaller" "https://www.microsoft.com/store/productId/9NBLGGH4NNS1"
winget install Logitech.SetPoint
winget install Microsoft.WindowsTerminal
winget install Microsoft.PowerToys
winget install AgileBits.1Password
winget install Nvidia.GeForceExperience
winget install Discord.Discord
winget install OBSProject.OBSStudio
winget install VideoLAN.VLC
winget install Valve.Steam --location "C:\Games\Steam"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment