Files
winconfig/install.ps1

229 lines
14 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',
'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')
# Menü konfiguration
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' {
# Crap deinstallieren
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)) {
Write-Host "Lege Winget config an." -ForegroundColor Blue
try {
New-Item -Path "~\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json" -ItemType SymbolicLink -Value "~/.winconfig/configs/winget/settings.json" | Out-Null
Write-Host "Winget config erfolgreich verlinkt." -ForegroundColor Green
}
catch {
Write-Host "Probleme beim verlinken der Wignet configt" -ForegroundColor Red
}
}
else {
Write-Host "Lege Winget config an." -ForegroundColor Blue
Remove-Item "~\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json"
try {
New-Item -Path "~\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json" -ItemType SymbolicLink -Value "~/.winconfig/configs/winget/settings.json" | Out-Null
Write-Host "Winget config erfolgreich verlinkt." -ForegroundColor Green
}
catch {
Write-Host "Probleme beim verlinken der Wignet configt" -ForegroundColor Red
}
}
# Software installieren.
foreach ($utility in $toInstall) {
$ergebnis = winget list --id $utility
if ($ergebnis -eq "Es wurde kein installiertes Paket gefunden, das den Eingabekriterien entspricht.") {
Try {
winget install -e --id $utility --silent
}
Catch {
Write-Host "Paket $utility konnte nicht installiert werden. " -ForegroundColor Red
}
}
else {
Write-Host "Programm $utility bereits installiert" -ForegroundColor Green
}
}
# OOShutup10 herunterladen und config reinrendenr.
Write-Host "Lade OOshutup10 herunter bitte warten..." -ForegroundColor Blue
Try {
curl.exe -s "https://dl5.oo-software.com/files/ooshutup10/OOSU10.exe" -o OOSU10.exe
Write-Host "OOshutup10 erfolgreich heruntergeladen." -ForegroundColor Green
Write-Host "Versuche OOshutup10 config einzulesen..." -ForegroundColor Blue
./OOSU10.exe $HOME\.winconfig\configs\ooshutup10\ooshutup10.cfg /quiet
Write-Host "OOshutup10 config erfolgreich eingelesen." -ForegroundColor Green
}
Catch {
Write-Host "Problem beim herunterladen von OOshutup 10." -ForegroundColor Red
}
Write-Host "Richte Powershell und Terminal ein..." -ForegroundColor Blue
# Fonts installieren.
$LocalPath = "~/.winconfig/Fonts/"
$FONTS = 0x14
$objShell = New-Object -ComObject Shell.Application
$objFolder = $objShell.Namespace($FONTS)
$Fontdir = Get-ChildItem $LocalPath
foreach ($File in $Fontdir) {
Write-Host "Versuche Schriftart $File zu installieren ..." -ForegroundColor Blue
Try {
if ((Test-Path "C:\Windows\Fonts\$File") -eq $False) {
$objFolder.CopyHere($File.fullname, 0x10)
}
Write-Host "Schriftart $File erfolgreich installiert." -ForegroundColor Green
}
Catch {
Write-Host "Probleme beim installieren der Schriftart $File" -ForegroundColor Red
}
}
# Windows Terminal Settings
Write-Host "Richte Windows Terminal config ein..." -ForegroundColor Blue
Try {
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" | Out-Null
Write-Host "Windows Terminal config erfolgreich eingerichtet" -ForegroundColor Green
}
Catch {
Write-Host "Fehler beim einrichten der Windows Terminal config." -ForegroundColor Red
}
# Winfetch installieren & konfigurieren
Write-Host "Installiere und konfiguriere Winfetch..." -ForegroundColor Blue
Try {
Install-Script winfetch
Write-Host "Winfetch erfolgreich installiert." -ForegroundColor Green
if ((Test-Path ~/.config/winfetch -PathType Leaf) -eq $True) {
Write-Host "Lösche default config..." -ForegroundColor Blue
Remove-Item -Recurse -Force ~/.config/winfetch
}
Write-Host "Lege Winfetch config Ordner an..." -ForegroundColor Blue
mkdir ~/.config/winfetch | Out-Null
Write-Host "Winfetch config Ordner erfolgreich angelegt!" -ForegroundColor Green
Try {
New-Item -Path "~/.config/winfetch/config.ps1" -ItemType SymbolicLink -Value "~/.winconfig/configs/winfetch/config.ps1" | Out-Null
Write-Host "Winfetch config sauber gelinkt." -ForegroundColor Green
}
Catch {
Write-Host "Probleme beim verlinken der Winfetch config" -ForegroundColor Red
}
}
Catch {
Write-Host "Probleme beim installieren von Winfetch" -ForegroundColor Red
}
# Powershell Profile Datei erzeugen
Write-Host "Löschen des default Powershell profiles..." -ForegroundColor Blue
if ((Test-Path "~/Documents/PowerShell/profile.ps1" -PathType Leaf) -eq $True) {
Remove-Item -Force "~/Documents/PowerShell/profile.ps1"
Write-Host "Powershell config erfolgreich gelöscht." -ForegroundColor Green
Try {
New-Item -Path "~/Documents/PowerShell/profile.ps1" -ItemType SymbolicLink -Value "~/.winconfig/profile.ps1" | Out-Null
Write-Host "Powershell config erfolgreich verlinkt."
}
Catch {
Write-Host "Probleme beim verlinken der Powershell config." -ForegroundColor Red
}
}
elseif ((Test-Path "~/Documents/WindowsPowerShell/profile.ps1" -PathType Leaf) -eq $True) {
Remove-Item -Force "~/Documents/WindowsPowerShell/profile.ps1"
Write-Host "Powershell config erfolgreich gelöscht." -ForegroundColor Green
Try {
New-Item -Path "~/Documents/PowerShell/profile.ps1" -ItemType SymbolicLink -Value "~/.winconfig/profile.ps1" | Out-Null
Write-Host "Powershell config erfolgreich verlinkt."
}
Catch {
Write-Host "Probleme beim verlinken der Powershell config." -ForegroundColor Red
}
}
# Powershell Modul für Updates
Try {
Install-Module -Name PSWindowsUpdate -Force
Write-Host "Powershell update Modul erfolgreich installiert..." -ForegroundColor Green
}
Catch {
Write-Host "Fehler beim installieren des Powershell update Modul." -ForegroundColor Red
}
Read-Host "Bitte das Terminal / Powershell neu starten damit die Aenderungen uebernommen werden."
} '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
}
}
}
$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
}
}
pause
}
until ($selection -eq 'q')
Stop-Transcript