Win_Setup/setup.ps1

183 lines
6.6 KiB
PowerShell
Raw Normal View History

2024-05-13 17:52:01 -05:00
## NOT TESTED ##
#Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe
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-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) {
winget install --exact $app.name --source $app.source
# winget install --exact --silent $app.name --source $app.source
2024-05-13 16:20:12 -05:00
}
else {
2024-05-13 16:31:39 -05:00
winget install --exact $app.name
# 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 15:06:11 -05:00
# Get-Content -Path $PROFILE
$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
# Get-Content -Path $PROFILE
#>
<#
Write-Output '
Register-ArgumentCompleter -Native -CommandName winget -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
[Console]::InputEncoding = [Console]::OutputEncoding = $OutputEncoding = [System.Text.Utf8Encoding]::new()
$Local:word = $wordToComplete.Replace('"', '""')
$Local:ast = $commandAst.ToString().Replace('"', '""')
winget complete --word="$Local:word" --commandline "$Local:ast" --position $cursorPosition | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
}' >> $PROFILE
#>
}
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' },
@{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' },
# @{name = 'Facebook.Messenger' }, # Cant find via winget anymore?
2024-05-13 14:57:51 -05:00
@{name = 'Microsoft.Office' },
@{name = 'Malwarebytes.Malwarebytes '}
2024-05-13 14:25:39 -05:00
)
2024-05-14 15:06:11 -05:00
InstallTheApps $Apps
Update-Profile
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' )