Win_Setup/setup.ps1
2024-05-21 16:31:13 -05:00

181 lines
6.5 KiB
PowerShell

## NOT TESTED ##
#Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe
#Install WinGet
## WinGet should be on any windows 11 install by default
$hasPackageManager = Get-AppPackage -name 'Microsoft.DesktopAppInstaller'
if (!$hasPackageManager -or [version]$hasPackageManager.Version -lt [version]"1.10.0.0") {
"Installing winget Dependencies"
Add-AppxPackage -Path 'https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx'
$releases_url = 'https://api.github.com/repos/microsoft/winget-cli/releases/latest'
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$releases = Invoke-RestMethod -uri $releases_url
$latestRelease = $releases.assets | Where-Object { $_.browser_download_url.EndsWith('msixbundle') } | Select-Object -First 1
"Installing winget from $($latestRelease.browser_download_url)"
Add-AppxPackage -Path $latestRelease.browser_download_url
}
else {
"winget already installed"
}
#Configure WinGet
Write-Output "Configuring winget"
#winget config path from: https://github.com/microsoft/winget-cli/blob/master/doc/Settings.md#file-location
$settingsPath = "$env:LOCALAPPDATA\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json";
$settingsJson = @{installBehavior = @{
preferences = @{
scope = 'machine'
}
}
}
$settingsJson | ConvertTo-Json | Out-File $settingsPath -Encoding utf8
winget search test --accept-source-agreements
function InstallTheApps() {
Foreach ($app in $apps) {
$listApp = winget list --exact -q $app.name
if (![String]::Join("", $listApp).Contains($app.name)) {
Write-host "Installing:" $app.name
if ($null -ne $app.source) {
winget install --exact $app.name --source $app.source --accept-package-agreements
# winget install --exact --silent $app.name --source $app.source
}
else {
winget install --exact $app.name --accept-package-agreements
# winget install --exact --silent $app.name
}
}
else {
Write-host "Skipping Install of " $app.name
}
}
}
function Update-Profile {
#Check For $PROFILE
if (-not (Test-Path $PROFILE)) { $null = New-Item -Force $PROFILE }
#Grab "Helper File"
$URL="https://git.theflyingfool.com/theflyingfool/Win_Setup/raw/branch/main/CopyFromFile.txt"
$PATH="$PWD\CopyFromFile.txt"
if (-not (Test-Path ./CopyFromFile.txt)) { (New-Object System.Net.WebClient).DownloadFile($URL, $PATH) }
$CheckString = Get-Content -Path .\CopyFromFile.txt
if (-not(Select-String -Quiet -Path $PROFILE -Pattern $CheckString)) {Get-Content -Path .\CopyFromFile.txt | Add-Content -Path $PROFILE}
#Delete "Helper File"
Remove-Item .\CopyFromFile.txt
}
do {
$answer = $null
do {
if ( $answer) {
Write-Host 'Invalid selection'
Start-Sleep 2
Write-Host ''
}
Write-Host '1 - Base Apps'
Write-Host '2 - Game Launchers'
Write-Host '3 - Desktop only'
Write-Host '4 - Lenovo Laptop only'
Write-Host '5 - Remove Crap'
Write-Host '9 - Exit'
Write-Host ''
$answer = Read-Host 'Select number(s)'
$ok =$answer -in @(1..5; 9)
} until ($ok)
if ($answer -eq 9) { break }
switch ( $answer ) {
"1" { $apps = @( # BASE APPS
@{name = 'Microsoft.PowerShell' },
@{name = 'Microsoft.VisualStudioCode' },
@{name = 'Microsoft.WindowsTerminal'},
@{name = 'Microsoft.PowerToys' },
@{name = 'Git.Git' },
@{name =' ApacheFriends.Xampp.8.2'},
@{name = 'Google.Chrome' },
@{name = 'TorProject.TorBrowser'},
@{name = 'Google.GoogleDrive' },
@{name = 'Hugo.Hugo.Extended' },
@{name = 'Bitwarden.Bitwarden' },
@{name = 'Sinew.Enpass'}, # Temp until everything moved to bitwarden
@{name = 'Plex.Plex' },
@{name = 'Microsoft.MouseWithoutBorders'},
@{name = 'Vivaldi.Vivaldi' },
@{name = 'VideoLAN.VLC' },
@{name = 'PointPlanck.FileBot' },
@{name = 'Oracle.VirtualBox' },
@{name = 'NordSecurity.NordVPN' },
@{name = '9wzdncrf0083'}, #Facebook messenger
@{name = 'Microsoft.Office' },
@{name = 'Malwarebytes.Malwarebytes '},
@{name = 'Google.AndroidStudio'}
)
InstallTheApps $Apps
Update-Profile
Write-Host "Make sure SSH Client is installed"
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
Write-Host "Create SSH Key"
ssh-keygen -t ed25519
Write-Host "Start SSH Agent"
Get-Service ssh-agent | Set-Service -StartupType Automatic
Start-Service ssh-agent
ssh-add $env:USERPROFILE\.ssh\id_ed25519
}
"2" {
$apps = @( # Game Launchers
@{name = 'ElectronicArts.EADesktop' },
@{name = 'Valve.Steam' },
@{name = 'EpicGames.EpicGamesLauncher' },
@{name = 'GOG.Galaxy '},
@{name = 'Discord.Discord '}
)
InstallTheApps $Apps
}
"3" {
$apps = @( ## DESKTOP
@{name = 'SteelSeries.SteelSeriesEngine' },
@{name = 'Corsair.iCUE.5' },
@{name = 'Asus.ArmouryCrate '},
@{name = 'Nvidia.GeForceExperience '}
)
InstallTheApps $Apps
}
"4" { $apps = @( ## LAPTOP
@{name = 'Intel.IntelDriverAndSupportAssistant' },
@{name = '9WZDNCRFJ4MV'; source = 'msstore' }, # Lenovo Vantage from MS Store
@{name = 'j5create.Driver-JUA365' } ## Not sure if this is correct yet!
)
InstallTheApps $Apps
}
'5' {
## REMOVE CRAP
Write-Output 'Removing Apps'
$apps = '*3DPrint*', 'Microsoft.MixedReality.Portal', 'Disney.*' , 'Microsoft.BingNews*' , '*BingWeather*', '*.MicrosoftOfficeHub*' , '*MicrosoftSolitaireCollection*'
Foreach ($app in $apps) {
Write-Host 'Uninstalling:' $app
Get-AppxPackage -allusers $app | Remove-AppxPackage
}
}
}
} until ( $answer -eq '9' )