Windows Terminal anpassung verbessert.

This commit is contained in:
2022-12-31 16:43:56 +01:00
parent c7e0c5f755
commit 2b06155781

View File

@@ -8,6 +8,18 @@ if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdenti
Break Break
} }
# Funktion um zu prüfen ob die config Files schon vorhanden sind.
function CheckForLink ($Path) {
if (((Get-Item $Path).LinkType -eq "SymbolicLink")) {
Return $True
}
else {
Return $False
}
}
# Konfig für die prompts # Konfig für die prompts
$choices = New-Object Collections.ObjectModel.Collection[Management.Automation.Host.ChoiceDescription] $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 '&Yes'))
@@ -65,6 +77,7 @@ do {
} }
} }
else { else {
if (CheckForLink(~\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json) -eq $False) {
Write-Host "Lege Winget config an." -ForegroundColor Blue Write-Host "Lege Winget config an." -ForegroundColor Blue
Remove-Item "~\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json" Remove-Item "~\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json"
try { try {
@@ -74,6 +87,8 @@ do {
catch { catch {
Write-Host "Probleme beim verlinken der Wignet configt" -ForegroundColor Red Write-Host "Probleme beim verlinken der Wignet configt" -ForegroundColor Red
} }
}
} }
# Software installieren. # Software installieren.
foreach ($utility in $toInstall) { foreach ($utility in $toInstall) {
@@ -123,6 +138,7 @@ do {
} }
# Windows Terminal Settings # Windows Terminal Settings
Write-Host "Richte Windows Terminal config ein..." -ForegroundColor Blue Write-Host "Richte Windows Terminal config ein..." -ForegroundColor Blue
if (CheckForLink(~\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json) -eq $False) {
Try { 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 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 Write-Host "Windows Terminal config erfolgreich eingerichtet" -ForegroundColor Green
@@ -130,7 +146,13 @@ do {
Catch { Catch {
Write-Host "Fehler beim einrichten der Windows Terminal config." -ForegroundColor Red Write-Host "Fehler beim einrichten der Windows Terminal config." -ForegroundColor Red
} }
}
# Winfetch installieren & konfigurieren # Winfetch installieren & konfigurieren
if (Get-Module -ListAvailable -Name winfetch) {
Write-Host "Winfetch ist bereits installiert." -ForegroundColor Blue
}
else {
Write-Host "Installiere und konfiguriere Winfetch..." -ForegroundColor Blue Write-Host "Installiere und konfiguriere Winfetch..." -ForegroundColor Blue
Try { Try {
Install-Script winfetch Install-Script winfetch
@@ -153,9 +175,15 @@ do {
Catch { Catch {
Write-Host "Probleme beim installieren von Winfetch" -ForegroundColor Red Write-Host "Probleme beim installieren von Winfetch" -ForegroundColor Red
} }
}
if (CheckForLink(~/.config/winfetch/config.ps1) -eq $False) {
Remove-Item "~/.config/winfetch/config.ps1"
New-Item -Path "~/.config/winfetch/config.ps1" -ItemType SymbolicLink -Value "~/.winconfig/configs/winfetch/config.ps1" | Out-Null
}
# Powershell Profile Datei erzeugen # Powershell Profile Datei erzeugen
Write-Host "Löschen des default Powershell profiles..." -ForegroundColor Blue Write-Host "Löschen des default Powershell profiles..." -ForegroundColor Blue
if ((Test-Path "~/Documents/PowerShell/profile.ps1" -PathType Leaf) -eq $True) { if ((Test-Path "~/Documents/PowerShell/profile.ps1" -PathType Leaf) -eq $True) {
if (CheckForLink(~/Documents/PowerShell/profile.ps1) -eq $False) {
Remove-Item -Force "~/Documents/PowerShell/profile.ps1" Remove-Item -Force "~/Documents/PowerShell/profile.ps1"
Write-Host "Powershell config ~/Documents/PowerShell/profile.ps1 erfolgreich gelöscht." -ForegroundColor Green Write-Host "Powershell config ~/Documents/PowerShell/profile.ps1 erfolgreich gelöscht." -ForegroundColor Green
Try { Try {
@@ -166,36 +194,22 @@ do {
Write-Host "Probleme beim verlinken der Powershell config ~/Documents/PowerShell/profile.ps1 " -ForegroundColor Red Write-Host "Probleme beim verlinken der Powershell config ~/Documents/PowerShell/profile.ps1 " -ForegroundColor Red
} }
} }
else {
Try {
New-Item -Path "~/Documents/PowerShell/profile.ps1" -ItemType SymbolicLink -Value "~/.winconfig/profile.ps1" | Out-Null
Write-Host "Powershell config ~/Documents/PowerShell/profile.ps1 erfolgreich verlinkt."
}
Catch {
Write-Host "Probleme beim verlinken der Powershell config ~/Documents/PowerShell/profile.ps1 " -ForegroundColor Red
}
} }
if ((Test-Path "~/Documents/WindowsPowerShell/profile.ps1" -PathType Leaf) -eq $True) { if ((Test-Path "~/Documents/WindowsPowerShell/profile.ps1" -PathType Leaf) -eq $True) {
if (CheckForLink(~/Documents/WindowsPowerShell/profile.ps1) -eq $False) {
Remove-Item -Force "~/Documents/WindowsPowerShell/profile.ps1" Remove-Item -Force "~/Documents/WindowsPowerShell/profile.ps1"
Write-Host "Powershell config ~/Documents/WindowsPowerShell/profile.ps1 erfolgreich gelöscht." -ForegroundColor Green Write-Host "Powershell config ~/Documents/WindowsPowerShell/profile.ps1 erfolgreich gelöscht." -ForegroundColor Green
Try { Try {
New-Item -Path "~/Documents/PowerShell/profile.ps1" -ItemType SymbolicLink -Value "~/.winconfig/profile.ps1" | Out-Null New-Item -Path "~/Documents/WindowsPowerShell/profile.ps1" -ItemType SymbolicLink -Value "~/.winconfig/profile.ps1" | Out-Null
Write-Host "Powershell config ~/Documents/WindowsPowerShell/profile.ps1 erfolgreich verlinkt." Write-Host "Powershell config ~/Documents/WindowsPowerShell/profile.ps1 erfolgreich verlinkt."
} }
Catch { Catch {
Write-Host "Probleme beim verlinken der Powershell config ~/Documents/PowerShell/profile.ps1" -ForegroundColor Red Write-Host "Probleme beim verlinken der Powershell config ~/Documents/WindowsPowerShell/profile.ps1" -ForegroundColor Red
} }
} }
else {
Try {
New-Item -Path "~/Documents/PowerShell/profile.ps1" -ItemType SymbolicLink -Value "~/.winconfig/profile.ps1" | Out-Null
Write-Host "Powershell config ~/Documents/WindowsPowerShell/profile.ps1 erfolgreich verlinkt."
}
Catch {
Write-Host "Probleme beim verlinken der Powershell config ~/Documents/PowerShell/profile.ps1" -ForegroundColor Red
}
} }
if ((Test-Path "~/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1" -PathType Leaf) -eq $True) { if ((Test-Path "~/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1" -PathType Leaf) -eq $True) {
if (CheckForLink("~/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1") -eq $True) {
Remove-Item -Force "~/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1" Remove-Item -Force "~/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1"
Write-Host "Powershell ~/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1 config erfolgreich gelöscht." -ForegroundColor Green Write-Host "Powershell ~/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1 config erfolgreich gelöscht." -ForegroundColor Green
Try { Try {
@@ -206,16 +220,13 @@ do {
Write-Host "Probleme beim verlinken der Powershell config ~/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1 ." -ForegroundColor Red Write-Host "Probleme beim verlinken der Powershell config ~/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1 ." -ForegroundColor Red
} }
} }
else {
Try {
New-Item -Path "~\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1" -ItemType SymbolicLink -Value "~/.winconfig/profile.ps1" | Out-Null
Write-Host "Powershell config ~/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1 erfolgreich verlinkt."
}
Catch {
Write-Host "Probleme beim verlinken der Powershell config ~/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1 ." -ForegroundColor Red
} <# Action when all if and elseif conditions are false #>
} }
# Powershell Modul für Updates # Powershell Modul für Updates
if (Get-Module -ListAvailable -Name PSWindowsUpdate) {
Write-Hoste "Windows Update Powershell Modul ist bereits installiert." -ForegroundColor Blue
}
else {
Write-Host "Beginne mit der Insallation des Powershell Update Modul..." -ForegroundColor Blue Write-Host "Beginne mit der Insallation des Powershell Update Modul..." -ForegroundColor Blue
Try { Try {
Install-Module -Name PSWindowsUpdate -Force Install-Module -Name PSWindowsUpdate -Force
@@ -224,6 +235,7 @@ do {
Catch { Catch {
Write-Host "Fehler beim installieren des Powershell update Modul." -ForegroundColor Red Write-Host "Fehler beim installieren des Powershell update Modul." -ForegroundColor Red
} }
}
Read-Host "Bitte das Terminal / Powershell neu starten damit die Aenderungen uebernommen werden." Read-Host "Bitte das Terminal / Powershell neu starten damit die Aenderungen uebernommen werden."
} '3' { } '3' {
@@ -255,11 +267,6 @@ do {
New-ItemProperty -path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'TaskbarSi' -value '0000001' -PropertyType DWORD 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" Write-Host "Starte Explorer neu um änderungen zu übernehmen"
Get-Process explorer | Stop-Process Get-Process explorer | Stop-Process
} }
} }
pause pause