Initial commit
This commit is contained in:
79
README.md
Normal file
79
README.md
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
# Winconfig
|
||||||
|
|
||||||
|
Aktuelle Windows config. Analog zu meiner [zshconfig](https://git.susa.pw/Tim/zshconfig).
|
||||||
|
Die Idee hinter diesem Script ist eine Windows 11 installation
|
||||||
|
so zu konfingurieren wie ich es mag. Es werden Einstellungen
|
||||||
|
am Explorer verändert, unnötige Software entfernt und nützliche Software installiert.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Ab Windows 11 ist winget installiert. Als erstes muss über die Powershell Git mit
|
||||||
|
<code>winget install -e --silent --id Git.Git</code> installieren.
|
||||||
|
Danach das repo clonen:
|
||||||
|
<code>git clone https://git.susa.pw/Tim/winconfig ~./winconfig</code>
|
||||||
|
Jetzt nach belieben die ExecutionPolicy setzen. Zum Beispiel:
|
||||||
|
<code>Set-ExecutionPolicy Unrestricted</code>
|
||||||
|
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Das aufrufen der <code>install.ps1</code> öffnet ein Menü das verschiedene Optionen bietet.
|
||||||
|
|
||||||
|
### Remove unwanted
|
||||||
|
|
||||||
|
Deinstalliert den default crap. Pakete können in dem Array <code>$toRemove</code> eingetragen werden.
|
||||||
|
|
||||||
|
### Installiere Software
|
||||||
|
|
||||||
|
Hier wid Software installiert die auch auf jeden Windows Computer benutzen möchte. Am Ende der Installation
|
||||||
|
startet das Programm [Shut Up Windows 10](https://www.oo-software.com/de/shutup10) damit ich es direkt konfigurieren kann.
|
||||||
|
Diese Software kann im Array $toInstall angepasst werden.
|
||||||
|
|
||||||
|
### Installiere optionale Software
|
||||||
|
|
||||||
|
Hier wird Software installiert, die nicht auf jeden Rechner den ich nutze installiert wird. Um flexibel zu bleiben fragt das Skript
|
||||||
|
bei jedem Tool einzeln nach ob eine Installation gewünsch ist oder nicht.
|
||||||
|
Diese Software kann im Array $toInstallOpt angepasst werden.
|
||||||
|
|
||||||
|
### Konfiguriere Windows
|
||||||
|
|
||||||
|
Hier werden Windows Einstellungen modifiziert.
|
||||||
|
- Ausgeblendete Dateien im Explorer anzeigen.
|
||||||
|
- Dateinamen Erweiterungen im Explorer anzeigen.
|
||||||
|
- Vollständigen Pfad im Explorer anzeigen.
|
||||||
|
- Erweitertest Kontextmenü im Explorer.
|
||||||
|
- Optionale Installation eines Powershell CMDlets um Windows Updates zu installieren.
|
||||||
|
|
||||||
|
### Update System
|
||||||
|
|
||||||
|
Dieser Programmpunkt updatet alle Winget Pakete, installiert alle Windows Updates und aktuallisert auch alle Powershell CMDlets.
|
||||||
|
|
||||||
|
## Nützliche commands
|
||||||
|
|
||||||
|
### Winget
|
||||||
|
#### Logfiles
|
||||||
|
<code>%LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir</code>
|
||||||
|
Man kann <code>--verbose-logs</code> winget command hängen um detailiertere Logs zu erhalten.
|
||||||
|
#### Zeige alle Software an
|
||||||
|
<code>winget list </code>
|
||||||
|
|
||||||
|
## To do
|
||||||
|
Noch ist dieses Repo nicht vollendet. Es fehlen noch folgende Fähigkeiten:
|
||||||
|
|
||||||
|
### Fehlende Software
|
||||||
|
Es gibt eine Handvoll Software für die kein Winget Paket verfügbar ist. Die Gründe dafür sind unterschiedlich.
|
||||||
|
- [Battl.net Client](https://www.blizzard.com/de-de/apps/battle.net/desktop)
|
||||||
|
- [Filezilla Client](https://filezilla-project.org/index.php)
|
||||||
|
- [MySQL Workbench](https://www.mysql.com/products/workbench/)
|
||||||
|
|
||||||
|
### Diverses
|
||||||
|
- Prüfen ob Installationsort einzelner Software angepasst werden soll.
|
||||||
|
- Falls winget irgendwann prüfen kann ob Software bereits installiert ist muss diese Abfrage angepasst werden.
|
||||||
|
- Falls winget irgendwann Ergebnisse von Abfragen sauber in <code>Select-Object</code> abfragbar macht muss die Namensbildung angepasst werden.
|
||||||
|
- Terminal hübsch machen. Für weitere Infos siehe [diesen Guide](https://dev.to/ansonh/customize-beautify-your-windows-terminal-2022-edition-541l).
|
||||||
|
- Prüfen inwieweit es möglich ist die Settings von Software automatisiert anzupassen.
|
||||||
|
- Sinnvolle Installation von Winfetch und der config.
|
||||||
|
- Anlage von aliases für das Terminal (update, modify).
|
||||||
|
- Beim Starten vom Terminal Winfetch starten.
|
||||||
|
- Winget Config syncen.
|
||||||
|
|
||||||
262
install.ps1
Normal file
262
install.ps1
Normal file
@@ -0,0 +1,262 @@
|
|||||||
|
[CmdletBinding()]
|
||||||
|
param (
|
||||||
|
[Parameter()]
|
||||||
|
# To exclude modules from the update process
|
||||||
|
[String[]]$ExcludedModules,
|
||||||
|
# To include only these modules for the update process
|
||||||
|
[String[]]$IncludedModules,
|
||||||
|
[switch]$SkipPublisherCheck,
|
||||||
|
[switch]$SimulationMode
|
||||||
|
)
|
||||||
|
|
||||||
|
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
|
||||||
|
|
||||||
|
# if needed, register PSGallery
|
||||||
|
# Register PSGallery PSprovider and set as Trusted source
|
||||||
|
# Register-PSRepository -Default -ErrorAction SilentlyContinue
|
||||||
|
# Set-PSRepository -Name PSGallery -InstallationPolicy trusted -ErrorAction SilentlyContinue
|
||||||
|
## 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')
|
||||||
|
$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')
|
||||||
|
$toInstallOpt = @('Element.Element','CPUID.CPU-Z','Discord.Discord','Corsair.iCUE.4','Valve.Steam','GOG.Galaxy')
|
||||||
|
|
||||||
|
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 "5: Update System"
|
||||||
|
Write-Host "Q: Beenden"
|
||||||
|
}
|
||||||
|
do {
|
||||||
|
Show-Menu
|
||||||
|
$selection = Read-Host "Bitte Aufgabe auswählen"
|
||||||
|
switch ($selection) {
|
||||||
|
'1' {
|
||||||
|
foreach ($utility in $toRemove) {
|
||||||
|
winget uninstall --id $utility
|
||||||
|
}
|
||||||
|
|
||||||
|
} '2' {
|
||||||
|
foreach ($utility in $toInstall) {
|
||||||
|
$ergebnis = winget list --id $utility
|
||||||
|
if ($ergebnis -eq "Es wurde kein installiertes Paket gefunden, das den Eingabekriterien entspricht.") {
|
||||||
|
winget install -e --id $utility --silent
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Host "Programm $utility bereits installiert"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Start-Process OOSU10 -NoNewWindow -Wait
|
||||||
|
} '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
|
||||||
|
}
|
||||||
|
} '4' {
|
||||||
|
$decision = $Host.UI.PromptForChoice('Explorer', 'Soll das Kontextmenü von Windows 10 wiederhergestellt werden?' , $choices, 1)
|
||||||
|
if ($decision -eq 0) {
|
||||||
|
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'
|
||||||
|
Write-Host "Starte Explorer neu um änderungen zu übernehmen"
|
||||||
|
Get-Process explorer | Stop-Process
|
||||||
|
}
|
||||||
|
if (!(Get-Module -ListAvailable -Name PSWindowsUpdate)) {
|
||||||
|
$decision = $Host.UI.PromptForChoice('Updates', 'Soll das Powershell Modul zum updaten von Windows installiert werden?' , $choices, 1)
|
||||||
|
if ($decision -eq 0) {
|
||||||
|
Install-Module -Name PSWindowsUpdate -Force
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} '5' {
|
||||||
|
Write-Host "Beginne mit dem Update aller Pakete..."
|
||||||
|
winget upgrade --all --accept-package-agreements --accept-source-agreements
|
||||||
|
if (Get-Module -ListAvailable -Name PSWindowsUpdate) {
|
||||||
|
Write-Host "Installiere Windows Updates..."
|
||||||
|
Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -IgnoreReboot
|
||||||
|
Write-Host "Update aller Powershell Module..."
|
||||||
|
if ($SimulationMode) {
|
||||||
|
Write-Host -ForegroundColor yellow 'Simulation mode is ON, nothing will be installed / removed / updated'
|
||||||
|
}
|
||||||
|
Write-Host -ForegroundColor Cyan 'Get all PowerShell modules'
|
||||||
|
function Remove-OldPowerShellModules {
|
||||||
|
param (
|
||||||
|
[string]$ModuleName,
|
||||||
|
[string]$GalleryVersion
|
||||||
|
)
|
||||||
|
|
||||||
|
try {
|
||||||
|
$oldVersions = Get-InstalledModule -Name $ModuleName -AllVersions -ErrorAction Stop | Where-Object { $_.Version -ne $GalleryVersion }
|
||||||
|
|
||||||
|
foreach ($oldVersion in $oldVersions) {
|
||||||
|
Write-Host -ForegroundColor Cyan "$ModuleName - Uninstall previous version ($($oldVersion.Version))"
|
||||||
|
if (-not($SimulationMode)) {
|
||||||
|
Remove-Module $ModuleName -ErrorAction SilentlyContinue
|
||||||
|
Uninstall-Module $oldVersion -Force -ErrorAction Stop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Warning "$module - $($_.Exception.Message)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($IncludedModules) {
|
||||||
|
$modules = Get-InstalledModule | Where-Object { $IncludedModules -contains $_.Name }
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$modules = Get-InstalledModule
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($module in $modules.Name) {
|
||||||
|
if ($ExcludedModules -contains $module) {
|
||||||
|
Write-Host -ForegroundColor Yellow "Module $module is excluded from the update process"
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
elseif ($module -like "$excludedModules") {
|
||||||
|
Write-Host -ForegroundColor Yellow "Module $module is excluded from the update process (match $excludeModules)"
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
$currentVersion = $null
|
||||||
|
|
||||||
|
try {
|
||||||
|
$currentVersion = (Get-InstalledModule -Name $module -AllVersions -ErrorAction Stop).Version
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Warning "$module - $($_.Exception.Message)"
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$moduleGalleryInfo = Find-Module -Name $module -ErrorAction Stop
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Warning "$module not found in the PowerShell Gallery. $($_.Exception.Message)"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($null -eq $currentVersion) {
|
||||||
|
Write-Host -ForegroundColor Cyan "$module - Install from PowerShellGallery version $($moduleGalleryInfo.Version) - Release date: $($moduleGalleryInfo.PublishedDate)"
|
||||||
|
|
||||||
|
if (-not($SimulationMode)) {
|
||||||
|
try {
|
||||||
|
Install-Module -Name $module -Force -SkipPublisherCheck -ErrorAction Stop
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Warning "$module - $($_.Exception.Message)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif ($moduleGalleryInfo.Version -eq $currentVersion) {
|
||||||
|
Write-Host -ForegroundColor Green "$module already in latest version: $currentVersion - Release date: $($moduleGalleryInfo.PublishedDate)"
|
||||||
|
}
|
||||||
|
elseif ($currentVersion.count -gt 1) {
|
||||||
|
Write-Host -ForegroundColor Yellow "$module is installed in $($currentVersion.count) versions (versions: $($currentVersion -join ' | '))"
|
||||||
|
Write-Host -ForegroundColor Cyan "$module - Uninstall previous $module version(s) below the latest version ($($moduleGalleryInfo.Version))"
|
||||||
|
|
||||||
|
Remove-OldPowerShellModules -ModuleName $module -GalleryVersion $moduleGalleryInfo.Version
|
||||||
|
|
||||||
|
# Check again the current Version as we uninstalled some old versions
|
||||||
|
$currentVersion = (Get-InstalledModule -Name $module).Version
|
||||||
|
|
||||||
|
if ($moduleGalleryInfo.Version -ne $currentVersion) {
|
||||||
|
Write-Host -ForegroundColor Cyan "$module - Install from PowerShellGallery version $($moduleGalleryInfo.Version) - Release date: $($moduleGalleryInfo.PublishedDate)"
|
||||||
|
if (-not($SimulationMode)) {
|
||||||
|
try {
|
||||||
|
Install-Module -Name $module -Force -ErrorAction Stop
|
||||||
|
|
||||||
|
Remove-OldPowerShellModules -ModuleName $module -GalleryVersion $moduleGalleryInfo.Version
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Warning "$module - $($_.Exception.Message)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# https://invoke-thebrain.com/2018/12/comparing-version-numbers-powershell/
|
||||||
|
elseif ([version]$currentVersion -gt [version]$moduleGalleryInfo.Version) {
|
||||||
|
Write-Host -ForegroundColor Yellow "$module - the current version $currentVersion is newer than the version available on PowerShell Gallery $($moduleGalleryInfo.Version) (Release date: $($moduleGalleryInfo.PublishedDate)). Sometimes happens when you install a module from another repository or via .exe/.msi or if you change the version number manually."
|
||||||
|
}
|
||||||
|
elseif ([version]$currentVersion -lt [version]$moduleGalleryInfo.Version) {
|
||||||
|
Write-Host -ForegroundColor Cyan "$module - Update from PowerShellGallery version " -NoNewline
|
||||||
|
Write-Host -ForegroundColor White "$currentVersion -> $($moduleGalleryInfo.Version) " -NoNewline
|
||||||
|
Write-Host -ForegroundColor Cyan "- Release date: $($moduleGalleryInfo.PublishedDate)"
|
||||||
|
|
||||||
|
if (-not($SimulationMode)) {
|
||||||
|
try {
|
||||||
|
Update-Module -Name $module -Force -ErrorAction Stop
|
||||||
|
Remove-OldPowerShellModules -ModuleName $module -GalleryVersion $moduleGalleryInfo.Version
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
if ($_.Exception.Message -match 'Authenticode') {
|
||||||
|
Write-Host -ForegroundColor Yellow "$module - The module certificate used by the creator is either changed since the last module install or the module sign status has changed."
|
||||||
|
|
||||||
|
if ($SkipPublisherCheck.IsPresent) {
|
||||||
|
Write-Host -ForegroundColor Cyan "$module - SkipPublisherCheck Parameter is present, so install will run without Authenticode check"
|
||||||
|
Write-Host -ForegroundColor Cyan "$module - Install from PowerShellGallery version $($moduleGalleryInfo.Version) - Release date: $($moduleGalleryInfo.PublishedDate)"
|
||||||
|
try {
|
||||||
|
Install-Module -Name $module -Force -SkipPublisherCheck
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Warning "$module - $($_.Exception.Message)"
|
||||||
|
}
|
||||||
|
|
||||||
|
Remove-OldPowerShellModules -ModuleName $module -GalleryVersion $moduleGalleryInfo.Version
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Warning "$module - If you want to update this module, run again with -SkipPublisherCheck switch, but please keep in mind the security risk"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Warning "$module - $($_.Exception.Message)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pause
|
||||||
|
}
|
||||||
|
until ($selection -eq 'q')
|
||||||
Reference in New Issue
Block a user