Error handling.
This commit is contained in:
135
install.ps1
135
install.ps1
@@ -56,32 +56,116 @@ do {
|
|||||||
} '2' {
|
} '2' {
|
||||||
# Winget config installieren
|
# Winget config installieren
|
||||||
if (-not(Test-Path -Path '~\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json' -PathType leaf)){
|
if (-not(Test-Path -Path '~\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json' -PathType leaf)){
|
||||||
|
Write-Host "Lege Winget config an." -ForegroundColor Green
|
||||||
New-Item -Path "~\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json" -ItemType SymbolicLink -Value "~/.winconfig/configs/winget/settings.json" | Out-Null
|
New-Item -Path "~\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json" -ItemType SymbolicLink -Value "~/.winconfig/configs/winget/settings.json" | Out-Null
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Write-Host "Lege Winget config an." -ForegroundColor Green
|
||||||
Remove-Item "~\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json"
|
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
|
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) {
|
foreach ($utility in $toInstall) {
|
||||||
$ergebnis = winget list --id $utility
|
$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.") {
|
if ($ergebnis -eq "Es wurde kein installiertes Paket gefunden, das den Eingabekriterien entspricht.") {
|
||||||
Try {
|
Try {
|
||||||
winget install -e --id $utility --silent
|
winget install -e --id $utility --silent
|
||||||
Write-Log -Level 'INFO' -Message 'Paket {0} erfolgreich installiert.' -Arguments $utility
|
|
||||||
}
|
}
|
||||||
Catch {
|
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
|
Write-Host "Paket $utility konnte nicht installiert werden. " -ForegroundColor Red
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Write-Host "Programm $utility bereits installiert" -ForegroundColor Green
|
Write-Host "Programm $utility bereits installiert" -ForegroundColor Green
|
||||||
Write-Log -Level 'INFO' -Message 'Paket {0} erfolgreich installiert.' -Arguments $utility
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
# 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..."
|
||||||
|
Try {
|
||||||
|
./OOSU10.exe ooshutup10.cfg /quiet
|
||||||
|
Write-Host "OOshutup10 config erfolgreich eingelesen." -ForegroundColor Green
|
||||||
|
}
|
||||||
|
Catch {
|
||||||
|
Write-Host "Probleme beim einlesen der OOshutup10 config" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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)
|
||||||
|
New-Item $LocalPath -type directory -Force
|
||||||
|
$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"
|
||||||
|
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) -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
|
||||||
|
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
|
||||||
|
Try {
|
||||||
|
Remove-Item -Force "~/Documents/WindowsPowerShell/profile.ps1"
|
||||||
|
Write-Host "Powershell config erfolgreich gelöscht." -ForegroundColor Green
|
||||||
|
Try {
|
||||||
|
New-Item -Path "~/Documents/WindowsPowerShell/profile.ps1" -ItemType SymbolicLink -Value "~/.winconfig/profile.ps1"
|
||||||
|
Write-Host "Powershell config erfolgreich verlinkt."
|
||||||
|
}
|
||||||
|
Catch {
|
||||||
|
Write-Host "Probleme beim verlinken der Powershell config."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Catch {
|
||||||
|
Write-Host "Probleme beim löschen der default Powershell config." -ForegroundColor Red
|
||||||
|
}
|
||||||
|
|
||||||
|
Read-Host "Bitte das Terminal / Powershell neu starten damit die Aenderungen uebernommen werden." -Fore
|
||||||
|
|
||||||
} '3' {
|
} '3' {
|
||||||
foreach ($utility in $toInstallOpt) {
|
foreach ($utility in $toInstallOpt) {
|
||||||
$ergebnis = winget list --id $utility
|
$ergebnis = winget list --id $utility
|
||||||
@@ -92,35 +176,8 @@ do {
|
|||||||
winget install -e --id $utility --silent
|
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)
|
$decision = $Host.UI.PromptForChoice('WSL', 'Soll WSL mit Debian 11 installiert werden?' , $choices, 1)
|
||||||
if ($decision -eq 0) {
|
if ($decision -eq 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user