Files
winconfig/config.ps1

346 lines
19 KiB
PowerShell

# Enthält konfigurationen für das Script
# 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 = @('7zip.7zip', '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',
'yt-dlp.yt-dlp'.'Audacity.Audacity', 'ffmpeg', 'mp4-merge', 'AutoHotkey.AutoHotkey')
$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', 'Microsoft.SQLServerManagementStudio', 'Soundboard', 'VMware.WorkstationPro', 'OBSProject.OBSStudio', 'Microsoft.Teams')
# Deinstalliert den Crap
function RemoveSoftware {
$wingetResult = New-Object System.Collections.Generic.List[System.Object]
foreach ($utility in $toRemove) {
Try {
winget uninstall -e $utility
$wingetResult.Add("$node`n")
Start-Sleep -s 6
Wait-Process winget -Timeout 90 -ErrorAction SilentlyContinue
}
Catch {
Write-Host "Paket $utility konnte nicht deinstalliert werden. " -ForegroundColor red
}
}
$wingetResult.ToArray()
$wingetResult | ForEach-Object { $_ } | Out-Host
# Popup after finished
$ButtonType = [System.Windows.MessageBoxButton]::OK
if ($wingetResult -ne "") {
$Messageboxbody = "Deinstallierter Crap `n$($wingetResult)"
}
else {
$Messageboxbody = "Kein Crap deinstalliert."
}
$MessageIcon = [System.Windows.MessageBoxImage]::Information
[System.Windows.MessageBox]::Show($Messageboxbody, $AppTitle, $ButtonType, $MessageIcon)
}
# Installiert die Default Software
function InstallSoftware {
# 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 {
if (CheckForLink(~\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json) -eq $False) {
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 -e $utility
if ($ergebnis -eq "Es wurde kein installiertes Paket gefunden, das den Eingabekriterien entspricht.") {
Try {
winget install -e --id $utility --silent
# Killt Programme die nach der Installation automatisch die UI starten. Ätzend!
if ($utility -eq 'Famatech.AdvancedIPScanner' ) {
Start-Sleep -Seconds 5
taskkill /IM advanced_ip_scanner.exe | Out-Null
}
elseif ($utility -eq 'Microsoft.PowerToys') {
Start-Sleep -Seconds 5
taskkill /IM PowerToys.Settings.exe | Out-Null
}
elseif ($utility -eq 'ffmpeg') {
Write-Host "Installiere ffmpeg..." -ForegroundColor Blue
try {
curl.exe -L https://www.gyan.dev/ffmpeg/builds/ffmpeg-git-essentials.7z -o ~/.winconfig/ffmpeg.7z
& "C:\Program Files\7-Zip\7z.exe" e ~/.winconfig/ffmpeg.7z -o"c:\Program Files\ffmpeg\"
Remove-Item ~/.winconfig/ffmpeg.7z
Write-Host "ffmpeg wurde erfolgreich installiert." -ForegroundColor Green
}
catch {
Write-Host "Es ist ein Fehler bei der Installation von ffmpeg auftreten. Bitte das Log durchsuchen." -ForegroundColor Red
}
elseif ($utility -eq 'mp4-merge'){
Write-Host "Installiere mp4-merge..." -ForegroundColor Blue
try {
curl.exe -L https://github.com/gyroflow/mp4-merge/releases/download/v0.1.4/mp4_merge-windows64.exe -o C:\Windows\mp4merge.exe
Write-Host "mp4-merge wurde erfolgreich installiert." -ForegroundColor Green
}
catch {
Write-Host "Es ist ein Fehler bei der Installation von mp4-merge auftreten. Bitte das Log durchsuchen." -ForegroundColor Red
}
}
elseif ($utility -eq 'AutoHotkey.AutoHotkey'){
Write-Host "Installiere AutoHotkey..." -ForegroundColor Blue
try {
winget install -e --id AutoHotkey.AutoHotkey -l "C:\Program Files\AutoHotKey"
Write-Host "AutoHotkey wurde erfolgreich installiert." -ForegroundColor Green
}
catch {
Write-Host "Es ist ein Fehler bei der Installation von Autohotkey auftreten. Bitte das Log durchsuchen." -ForegroundColor Red
}
}
}
}
Catch {
Write-Host "Paket $utility konnte nicht installiert werden. " -ForegroundColor Red
}
}
else {
Write-Host "Programm $utility bereits installiert" -ForegroundColor Green
}
}
# OOShutup10 herunterladen und config reinrendern.
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
if (CheckForLink(~\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json) -eq $False) {
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
if (Get-Module -ListAvailable -Name winfetch) {
Write-Host "Winfetch ist bereits installiert." -ForegroundColor Blue
}
else {
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
}
}
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
Write-Host "Löschen des default Powershell profiles..." -ForegroundColor Blue
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"
Write-Host "Powershell config ~/Documents/PowerShell/profile.ps1 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 ~/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 (CheckForLink(~/Documents/WindowsPowerShell/profile.ps1) -eq $False) {
Remove-Item -Force "~/Documents/WindowsPowerShell/profile.ps1"
Write-Host "Powershell config ~/Documents/WindowsPowerShell/profile.ps1 erfolgreich gelöscht." -ForegroundColor Green
Try {
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."
}
Catch {
Write-Host "Probleme beim verlinken der Powershell config ~/Documents/WindowsPowerShell/profile.ps1" -ForegroundColor Red
}
}
}
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"
Write-Host "Powershell ~/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1 config erfolgreich gelöscht." -ForegroundColor Green
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
}
}
}
# Autohotkey in Startup
Write-Host "Verlinke AutoHokey Scripts ..." -ForegroundColor Blue
$sourceDir = "~\.winconfig\configs\autohotkey"
$targetDir = "~\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
Get-ChildItem -Path $sourceDir | ForEach-Object {
$linkPath = Join-Path $targetDir $_.Name
New-Item -ItemType SymbolicLink -Path $linkPath -Target $_.FullName -ErrorAction SilentlyContinue | Out-Null
}
Write-Host "AutoHotkey Scripts erfolgreich installiert." -ForegroundColor Green
# 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
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."
# 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' # Versteckte Files anzeigen
Set-Itemproperty -path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'HideFileExt' -value '00000000' # Fileextensions anzeigen lassen
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
Set-ItemProperty -path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer' -Name 'EnableAutoTray' -value '00000001' # Alle Tray Icons immer anzeigen
Write-Host "Starte Explorer neu um änderungen zu übernehmen"
Get-Process explorer | Stop-Process
}
# Funktion um optionale Software zu insatllieren
function InstallSoftwareOpt {
foreach ($utility in $toInstallOpt) {
$ergebnis = winget list --id -e $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) {
if (-Not $utility -eq 'Soundboard') {
Write-Host "Installiere $utility"
winget install -e --id $utility --silent
}
else {
Invoke-WebRequest -UseBasicParsing -Uri "https://www.leppsoft.com/soundpad/de/download/64/20230101-SZQED1RN/" `
-UserAgent "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:108.0) Gecko/20100101 Firefox/108.0" `
-Headers @{
"Accept" = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8"
"Accept-Language" = "de,en-US;q=0.7,en;q=0.3"
"Accept-Encoding" = "gzip, deflate, br"
"Referer" = "https://www.leppsoft.com/soundpad/de/download/64/20230101-U1KGSLJC/Soundpad_x64-3.4.10.msi"
"Upgrade-Insecure-Requests" = "1"
"Sec-Fetch-Dest" = "document"
"Sec-Fetch-Mode" = "navigate"
"Sec-Fetch-Site" = "same-origin"
"Sec-Fetch-User" = "?1"
}
}
}
}
}
$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!"
}
}
# Funktion um Windows zu debloaten
function DebloatWindows {
Write-Host "Beginne das Windows zu debloaten und hardening auszuführen..." - -ForegroundColor Blue
. .\debloat.ps1
debloatwindows
}
# 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
}
}