Files
winconfig/install.ps1
2022-12-30 16:10:50 +01:00

154 lines
9.4 KiB
PowerShell

# Log starten
Start-Transcript -Path $HOME/.winconfig/run.log
## Fragt nach Admin Rechten.
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
# Konfig für die prompts
$choices = New-Object Collections.ObjectModel.Collection[Management.Automation.Host.ChoiceDescription]
$choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&Yes'))
$choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&No'))
## Konfig für die Software
$toRemove = @('Clipchamp.Clipchamp_yxz26nhyzhsrt', 'Microsoft.549981C3F5F10_8wekyb3d8bbwe', 'Microsoft.BingNews_8wekyb3d8bbwe', 'Microsoft.BingWeather_8wekyb3d8bbwe', 'Microsoft.GetHelp_8wekyb3d8bbwe',
'Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe', 'Microsoft.MicrosoftSolitaireCollection_8wekyb3d8bbwe', 'Micorosoft.MicrosoftStickyNotes_8wekyb3d8bbwe', 'Microsoft.People_8wekyb3d8bbwe',
'Microsoft.PowerAutomateDesktop_8wekyb3d8bbwe', 'Microsoft.Todos_8wekyb3d8bbwe', 'Microsoft.Windows.Photos_8wekyb3d8bbwe', 'Microsoft.WindowsMaps_8wekyb3d8bbwe',
'Microsoft.WindowsSoundRecorder_8wekyb3d8bbwe', 'Microsoft.WindowsAlarms_8wekyb3d8bbwe', 'Microsoft.YourPhone_8wekyb3d8bbwe', 'Microsoft.ZuneMusic_8wekyb3d8bbwe', 'Microsoft.ZuneVideo_8wekyb3d8bbwe',
'MicrosoftCorporationII.QuickAssist_8wekyb3d8bbwe', 'MicrosoftTeams_8wekyb3d8bbwe', 'MicrosoftTeams_8wekyb3d8bbwe', 'Microsoft.OneDrive', 'microsoft.windowscommunicationsapps_8wekyb3d8bbwe', 'CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc')
$toInstall = @('mcmilk.7zip-zstd', 'VideoLAN.VLC', 'SumatraPDF.SumatraPDF', 'Microsoft.VisualStudioCode', 'Bitwarden.Bitwarden', 'Mozilla.Firefox', 'IrfanSkiljan.IrfanView', 'Microsoft.PowerToys', 'OO-Software.ShutUp10'
, 'Joplin.Joplin', 'WireGuard.WireGuard', 'Devolutions.RemoteDesktopManager', 'TeamViewer.TeamViewer', 'NickeManarin.ScreenToGif', 'JanDeDobbeleer.OhMyPosh', 'WiresharkFoundation.Wireshark', 'Famatech.AdvancedIPScanner')
$toInstallOpt = @('Element.Element', 'Discord.Discord', 'Corsair.iCUE.4', 'Valve.Steam', 'GOG.Galaxy', 'TeXstudio.TeXstudio', 'MiKTeX.MiKTeX', 'Citrix.Workspace', 'Nvidia.GeForceExperience', 'Mojang.MinecraftLauncher',
'Elgato.StreamDeck', 'REALiX.HWiNFO', '9P4CLT2RJ1RS', 'Oracle.VirtualBox')
function Show-Menu {
param (
[string]$Title = 'Software installation'
)
Clear-Host
Write-Host "================ $Title ================"
Write-Host "1: Remove unwanted"
Write-Host "2: Installiere Software"
Write-Host "3: Installiere optionale Software"
Write-Host "4: Konfiguriere Windows"
Write-Host "Q: Beenden"
}
do {
Show-Menu
$selection = Read-Host "Bitte Aufgabe auswählen"
switch ($selection) {
'1' {
foreach ($utility in $toRemove) {
Try {
winget uninstall --id $utility
}
Catch {
Write-Host "Paket $utility konnte nicht deinstalliert werden. " -ForegroundColor red
}
}
} '2' {
# Winget config installieren
if (-not(Test-Path -Path '~\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json' -PathType leaf)){
New-Item -Path "~\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json" -ItemType SymbolicLink -Value "~/.winconfig/configs/winget/settings.json" | Out-Null
}
else {
Remove-Item "~\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json"
New-Item -Path "~\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json" -ItemType SymbolicLink -Value "~/.winconfig/configs/winget/settings.json" | Out-Null
}
# Crap deinstallieren
foreach ($utility in $toInstall) {
$ergebnis = winget list --id $utility
Write-Log -Level 'INFO' -Message 'Versuche Paket {0} zu deinstallieren' -Arguments $utility
if ($ergebnis -eq "Es wurde kein installiertes Paket gefunden, das den Eingabekriterien entspricht.") {
Try {
winget install -e --id $utility --silent
Write-Log -Level 'INFO' -Message 'Paket {0} erfolgreich installiert.' -Arguments $utility
}
Catch {
Write-Log -Level 'ERROR' -Message 'Paket {0} konnte nicht installiert werden.' -Arguments $utility
Write-Log -Level 'ERROR' -Message '$_.Exception.Message' -Arguments $utility
Write-Host "Paket $utility konnte nicht installiert werden. " -ForegroundColor Red
}
}
else {
Write-Host "Programm $utility bereits installiert" -ForegroundColor Green
Write-Log -Level 'INFO' -Message 'Paket {0} erfolgreich installiert.' -Arguments $utility
}
}
} '3' {
foreach ($utility in $toInstallOpt) {
$ergebnis = winget list --id $utility
if ($ergebnis -eq "Es wurde kein installiertes Paket gefunden, das den Eingabekriterien entspricht.") {
$decision = $Host.UI.PromptForChoice("$utility", "Soll $utility installiert werden?" , $choices, 1)
if ($decision -eq 0) {
Write-Host "Installiere $utility"
winget install -e --id $utility --silent
}
}
}
# OOShutup10 herunterladen und config reinrendenr.
curl.exe -s "https://dl5.oo-software.com/files/ooshutup10/OOSU10.exe" -o OOSU10.exe
./OOSU10.exe ooshutup10.cfg /quiet
Write-Host "Richte Powershell und Terminal ein..."
# Fonts installieren.
$LocalPath = "~/.winconfig/Fonts/"
$FONTS = 0x14
$objShell = New-Object -ComObject Shell.Application
$objFolder = $objShell.Namespace($FONTS)
New-Item $LocalPath -type directory -Force
$Fontdir = Get-ChildItem $LocalPath
foreach ($File in $Fontdir) {
if ((Test-Path "C:\Windows\Fonts\$File") -eq $False) {
$objFolder.CopyHere($File.fullname, 0x10)
}
}
# Windows Terminal Settings
Remove-Item "~\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" ; New-Item -Path "~\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" -ItemType SymbolicLink -Value "~/.winconfig/configs/terminal/settings.json"
# Winfetch installieren & konfigurieren
Install-Script winfetch
Remove-Item -Recurse -Force ~/.config/winfetch
mkdir ~/.config/winfetch
New-Item -Path "~/.config/winfetch/config.ps1" -ItemType SymbolicLink -Value "~/.winconfig/configs/winfetch/config.ps1"
# Powershell Profile Datei erzeugen
Remove-Item -Force "~/Documents/WindowsPowerShell/profile.ps1"
New-Item -Path "~/Documents/WindowsPowerShell/profile.ps1" -ItemType SymbolicLink -Value "~/.winconfig/profile.ps1"
Read-Host "Bitte das Terminal / Powershell neu starten damit die Aenderungen uebernommen werden."
$decision = $Host.UI.PromptForChoice('WSL', 'Soll WSL mit Debian 11 installiert werden?' , $choices, 1)
if ($decision -eq 0) {
Write-Host "Installiere WSL"
wsl --install
Write-Host "Installiere Debian"
wsl --install -d Debian
Read-Host "Computer muss neugestartet werden!"
}
} '4' {
# Windows Explorer Einrichten
New-Item -Path "HKCU:\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" -Value "" -Force
Set-Itemproperty -path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'Hidden' -value '00000001'
Set-Itemproperty -path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'HideFileExt' -value '00000000'
Set-Itemproperty -path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CabinetState' -Name 'FullPath' -value '00000001'
Remove-ItemProperty -path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'TaskbarSi'
New-ItemProperty -path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'TaskbarSi' -value '0000001' -PropertyType DWORD
Write-Host "Starte Explorer neu um änderungen zu übernehmen"
Get-Process explorer | Stop-Process
# Powershell Modul für Updates
Install-Module -Name PSWindowsUpdate -Force
}
}
pause
}
until ($selection -eq 'q')
Stop-Transcript