Clean up / Linting

This commit is contained in:
Raphire
2025-05-07 15:51:01 +02:00
parent 8def22ac48
commit 8bc11bd7c8

View File

@@ -98,7 +98,7 @@ function ShowAppSelectionForm {
$global:SelectedApps = $selectionBox.CheckedItems $global:SelectedApps = $selectionBox.CheckedItems
# Create file that stores selected apps if it doesn't exist # Create file that stores selected apps if it doesn't exist
if (!(Test-Path "$PSScriptRoot/CustomAppsList")) { if (-not (Test-Path "$PSScriptRoot/CustomAppsList")) {
$null = New-Item "$PSScriptRoot/CustomAppsList" $null = New-Item "$PSScriptRoot/CustomAppsList"
} }
@@ -382,12 +382,12 @@ function RemoveApps {
try { try {
Get-AppxPackage -Name $app -AllUsers | Remove-AppxPackage -AllUsers -ErrorAction Continue Get-AppxPackage -Name $app -AllUsers | Remove-AppxPackage -AllUsers -ErrorAction Continue
if($DebugPreference -ne "SilentlyContinue") { if ($DebugPreference -ne "SilentlyContinue") {
Write-Host "Removed $app for all users" -ForegroundColor DarkGray Write-Host "Removed $app for all users" -ForegroundColor DarkGray
} }
} }
catch { catch {
if($DebugPreference -ne "SilentlyContinue") { if ($DebugPreference -ne "SilentlyContinue") {
Write-Host "Unable to remove $app for all users" -ForegroundColor Yellow Write-Host "Unable to remove $app for all users" -ForegroundColor Yellow
Write-Host $psitem.Exception.StackTrace -ForegroundColor Gray Write-Host $psitem.Exception.StackTrace -ForegroundColor Gray
} }
@@ -398,12 +398,12 @@ function RemoveApps {
try { try {
Get-AppxPackage -Name $app | Remove-AppxPackage -ErrorAction SilentlyContinue Get-AppxPackage -Name $app | Remove-AppxPackage -ErrorAction SilentlyContinue
if($DebugPreference -ne "SilentlyContinue") { if ($DebugPreference -ne "SilentlyContinue") {
Write-Host "Removed $app for current user" -ForegroundColor DarkGray Write-Host "Removed $app for current user" -ForegroundColor DarkGray
} }
} }
catch { catch {
if($DebugPreference -ne "SilentlyContinue") { if ($DebugPreference -ne "SilentlyContinue") {
Write-Host "Unable to remove $app for current user" -ForegroundColor Yellow Write-Host "Unable to remove $app for current user" -ForegroundColor Yellow
Write-Host $psitem.Exception.StackTrace -ForegroundColor Gray Write-Host $psitem.Exception.StackTrace -ForegroundColor Gray
} }
@@ -412,12 +412,12 @@ function RemoveApps {
try { try {
Get-AppxPackage -Name $app -PackageTypeFilter Main, Bundle, Resource -AllUsers | Remove-AppxPackage -AllUsers -ErrorAction SilentlyContinue Get-AppxPackage -Name $app -PackageTypeFilter Main, Bundle, Resource -AllUsers | Remove-AppxPackage -AllUsers -ErrorAction SilentlyContinue
if($DebugPreference -ne "SilentlyContinue") { if ($DebugPreference -ne "SilentlyContinue") {
Write-Host "Removed $app for all users" -ForegroundColor DarkGray Write-Host "Removed $app for all users" -ForegroundColor DarkGray
} }
} }
catch { catch {
if($DebugPreference -ne "SilentlyContinue") { if ($DebugPreference -ne "SilentlyContinue") {
Write-Host "Unable to remove $app for all users" -ForegroundColor Yellow Write-Host "Unable to remove $app for all users" -ForegroundColor Yellow
Write-Host $psitem.Exception.StackTrace -ForegroundColor Gray Write-Host $psitem.Exception.StackTrace -ForegroundColor Gray
} }
@@ -611,7 +611,7 @@ function ReplaceStartMenuForAllUsers {
$defaultStartMenuPath = $env:USERPROFILE -Replace ('\\' + $env:USERNAME + '$'), '\Default\AppData\Local\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState' $defaultStartMenuPath = $env:USERPROFILE -Replace ('\\' + $env:USERNAME + '$'), '\Default\AppData\Local\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState'
# Create folder if it doesn't exist # Create folder if it doesn't exist
if (-not(Test-Path $defaultStartMenuPath)) { if (-not (Test-Path $defaultStartMenuPath)) {
new-item $defaultStartMenuPath -ItemType Directory -Force | Out-Null new-item $defaultStartMenuPath -ItemType Directory -Force | Out-Null
Write-Output "Created LocalState folder for default user profile" Write-Output "Created LocalState folder for default user profile"
} }
@@ -673,7 +673,7 @@ function AddParameter {
} }
# Create or clear file that stores last used settings # Create or clear file that stores last used settings
if (!(Test-Path "$PSScriptRoot/SavedSettings")) { if (-not (Test-Path "$PSScriptRoot/SavedSettings")) {
$null = New-Item "$PSScriptRoot/SavedSettings" $null = New-Item "$PSScriptRoot/SavedSettings"
} }
elseif ($global:FirstSelection) { elseif ($global:FirstSelection) {
@@ -1194,7 +1194,11 @@ if (-not ($global:Params.ContainsKey("Verbose"))) {
$ProgressPreference = 'SilentlyContinue' $ProgressPreference = 'SilentlyContinue'
} }
else { else {
Read-Host "Verbose mode is enabled, press enter to continue" Write-Host "Verbose mode is enabled"
Write-Output ""
Write-Output "Press any key to continue..."
$null = [System.Console]::ReadKey()
$ProgressPreference = 'Continue' $ProgressPreference = 'Continue'
} }
@@ -1258,7 +1262,7 @@ if ((-not $global:Params.Count) -or $RunDefaults -or $RunWin11Defaults -or $RunS
$Mode = '1' $Mode = '1'
} }
elseif ($RunSavedSettings) { elseif ($RunSavedSettings) {
if(-not (Test-Path "$PSScriptRoot/SavedSettings")) { if (-not (Test-Path "$PSScriptRoot/SavedSettings")) {
PrintHeader 'Custom Mode' PrintHeader 'Custom Mode'
Write-Host "Error: No saved settings found, no changes were made" -ForegroundColor Red Write-Host "Error: No saved settings found, no changes were made" -ForegroundColor Red
AwaitKeyToExit AwaitKeyToExit
@@ -1301,7 +1305,7 @@ if ((-not $global:Params.Count) -or $RunDefaults -or $RunWin11Defaults -or $RunS
Write-Output "Press any key to go back..." Write-Output "Press any key to go back..."
$null = [System.Console]::ReadKey() $null = [System.Console]::ReadKey()
} }
elseif (($Mode -eq '4')-and -not (Test-Path "$PSScriptRoot/SavedSettings")) { elseif (($Mode -eq '4') -and -not (Test-Path "$PSScriptRoot/SavedSettings")) {
$Mode = $null $Mode = $null
} }
} }
@@ -1355,6 +1359,7 @@ if ((-not $global:Params.Count) -or $RunDefaults -or $RunWin11Defaults -or $RunS
# Suppress prompt if Silent parameter was passed # Suppress prompt if Silent parameter was passed
if (-not $Silent) { if (-not $Silent) {
Write-Output ""
Write-Output "" Write-Output ""
Write-Output "Press enter to remove the selected apps or press CTRL+C to quit..." Write-Output "Press enter to remove the selected apps or press CTRL+C to quit..."
Read-Host | Out-Null Read-Host | Out-Null