Win_Setup/setup.ps1

180 lines
6.5 KiB
PowerShell
Raw Normal View History

2024-05-21 16:37:16 -05:00
#Requires -RunAsAdministrator
2024-05-13 17:52:01 -05:00
2024-02-11 18:04:29 -06:00
#Install WinGet
## WinGet should be on any windows 11 install by default
2024-05-13 14:25:39 -05:00
$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"
}
2024-02-11 18:04:29 -06:00
#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";
2024-05-13 14:25:39 -05:00
$settingsJson = @{installBehavior = @{
preferences = @{
scope = 'machine'
}
}
}
$settingsJson | ConvertTo-Json | Out-File $settingsPath -Encoding utf8
2024-05-12 22:54:46 -05:00
2024-05-21 16:31:13 -05:00
winget search test --accept-source-agreements
2024-05-14 15:06:11 -05:00
2024-05-13 16:31:39 -05:00
function InstallTheApps() {
Foreach ($app in $apps) {
2024-05-13 16:20:12 -05:00
$listApp = winget list --exact -q $app.name
2024-05-13 16:31:39 -05:00
if (![String]::Join("", $listApp).Contains($app.name)) {
Write-host "Installing:" $app.name
if ($null -ne $app.source) {
2024-05-21 16:31:13 -05:00
winget install --exact $app.name --source $app.source --accept-package-agreements
2024-05-13 16:31:39 -05:00
# winget install --exact --silent $app.name --source $app.source
2024-05-13 16:20:12 -05:00
}
else {
2024-05-21 16:31:13 -05:00
winget install --exact $app.name --accept-package-agreements
2024-05-13 16:31:39 -05:00
# winget install --exact --silent $app.name
}
}
else {
Write-host "Skipping Install of " $app.name
2024-05-13 16:20:12 -05:00
}
}
}
2024-05-14 15:06:11 -05:00
function Update-Profile {
#Check For $PROFILE
2024-05-14 15:06:11 -05:00
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) }
2024-05-14 19:38:21 -05:00
$CheckString = Get-Content -Path .\CopyFromFile.txt
if (-not(Select-String -Quiet -Path $PROFILE -Pattern $CheckString)) {Get-Content -Path .\CopyFromFile.txt | Add-Content -Path $PROFILE}
2024-05-14 15:06:11 -05:00
2024-05-21 15:13:16 -05:00
#Delete "Helper File"
Remove-Item .\CopyFromFile.txt
2024-05-14 15:06:11 -05:00
}
2024-05-13 14:25:39 -05:00
do {
$answer = $null
do {
2024-05-12 22:54:46 -05:00
2024-05-13 14:25:39 -05:00
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)'
2024-05-13 16:58:32 -05:00
$ok =$answer -in @(1..5; 9)
} until ($ok)
2024-05-12 22:54:46 -05:00
2024-05-13 14:25:39 -05:00
if ($answer -eq 9) { break }
2024-05-12 22:54:46 -05:00
2024-05-13 16:20:12 -05:00
2024-05-12 22:54:46 -05:00
2024-05-13 14:25:39 -05:00
switch ( $answer ) {
2024-05-14 15:06:11 -05:00
"1" { $apps = @( # BASE APPS
2024-05-13 14:25:39 -05:00
@{name = 'Microsoft.PowerShell' },
@{name = 'Microsoft.VisualStudioCode' },
2024-05-13 14:57:51 -05:00
@{name = 'Microsoft.WindowsTerminal'},
2024-05-13 14:25:39 -05:00
@{name = 'Microsoft.PowerToys' },
@{name = 'Git.Git' },
2024-05-16 19:20:03 -05:00
@{name =' ApacheFriends.Xampp.8.2'},
2024-05-13 14:25:39 -05:00
@{name = 'Google.Chrome' },
2024-05-13 15:17:46 -05:00
@{name = 'TorProject.TorBrowser'},
@{name = 'Google.GoogleDrive' },
2024-05-13 14:25:39 -05:00
@{name = 'Hugo.Hugo.Extended' },
@{name = 'Bitwarden.Bitwarden' },
2024-05-13 14:57:51 -05:00
@{name = 'Sinew.Enpass'}, # Temp until everything moved to bitwarden
2024-05-13 14:25:39 -05:00
@{name = 'Plex.Plex' },
2024-05-13 14:57:51 -05:00
@{name = 'Microsoft.MouseWithoutBorders'},
@{name = 'Vivaldi.Vivaldi' },
2024-05-13 14:25:39 -05:00
@{name = 'VideoLAN.VLC' },
@{name = 'PointPlanck.FileBot' },
@{name = 'Oracle.VirtualBox' },
@{name = 'NordSecurity.NordVPN' },
2024-05-16 19:20:03 -05:00
@{name = '9wzdncrf0083'}, #Facebook messenger
2024-05-13 14:57:51 -05:00
@{name = 'Microsoft.Office' },
2024-05-15 09:39:40 -05:00
@{name = 'Malwarebytes.Malwarebytes '},
2024-05-23 09:11:22 -05:00
@{name = 'Google.AndroidStudio'}.
#@{name = 'Node.js'}, ## Was Testing Something
@{name = 'sqlitestudio.pl.SQLiteStudio'}
2024-05-13 14:25:39 -05:00
)
2024-05-14 15:06:11 -05:00
InstallTheApps $Apps
Update-Profile
2024-05-21 14:57:57 -05:00
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
2024-05-13 14:25:39 -05:00
}
"2" {
2024-05-13 14:25:39 -05:00
$apps = @( # Game Launchers
@{name = 'ElectronicArts.EADesktop' },
@{name = 'Valve.Steam' },
2024-05-13 14:57:51 -05:00
@{name = 'EpicGames.EpicGamesLauncher' },
@{name = 'GOG.Galaxy '},
@{name = 'Discord.Discord '}
2024-05-13 14:25:39 -05:00
)
InstallTheApps $Apps
2024-05-13 14:25:39 -05:00
}
"3" {
2024-05-13 14:25:39 -05:00
$apps = @( ## DESKTOP
@{name = 'SteelSeries.SteelSeriesEngine' },
2024-05-13 14:57:51 -05:00
@{name = 'Corsair.iCUE.5' },
@{name = 'Asus.ArmouryCrate '},
@{name = 'Nvidia.GeForceExperience '}
2024-05-13 14:25:39 -05:00
)
InstallTheApps $Apps
2024-05-13 14:25:39 -05:00
}
"4" { $apps = @( ## LAPTOP
2024-05-13 14:25:39 -05:00
@{name = 'Intel.IntelDriverAndSupportAssistant' },
2024-05-13 14:57:51 -05:00
@{name = '9WZDNCRFJ4MV'; source = 'msstore' }, # Lenovo Vantage from MS Store
@{name = 'j5create.Driver-JUA365' } ## Not sure if this is correct yet!
)
InstallTheApps $Apps
2024-05-13 16:58:32 -05:00
}
2024-05-13 17:52:01 -05:00
2024-05-13 14:25:39 -05:00
'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
2024-05-12 22:54:46 -05:00
}
}
}
2024-05-13 14:25:39 -05:00
} until ( $answer -eq '9' )