Remove Write-Debug (#4498)

* Update Invoke-WinUtilCurrentSystem.ps1

* Update Invoke-WinUtilFontScaling.ps1

* Update Invoke-WinUtilTweaks.ps1

* Update Reset-WPFCheckBoxes.ps1

* Update Set-Preferences.ps1

* Update Update-WinUtilSelections.ps1

* Update Invoke-WPFSelectedCheckboxesUpdate.ps1

* Update Invoke-WPFtweaksbutton.ps1

* Update main.ps1

* Update main.ps1

* Update main.ps1

* Update main.ps1

* Update main.ps1

* Merge branch 'main' into Remove-Write-Debug
This commit is contained in:
Gabi
2026-05-19 21:16:06 +03:00
committed by GitHub
parent a09736f9a8
commit 8034e85521
9 changed files with 7 additions and 98 deletions
@@ -117,10 +117,6 @@ Function Invoke-WinUtilCurrentSystem {
if ($values -notcontains $false) {
Write-Output $Config
}
} else {
if ($invokeScript -or $appxKeys) {
Write-Debug "Skipping $Config in Get Installed: no detectable registry, scheduled task, or service state."
}
}
}
}
@@ -67,7 +67,6 @@ function Invoke-WinUtilFontScaling {
# Calculates and applies the new font size
$newValue = [math]::Round($originalValue * $ScaleFactor, 1)
$sync.Form.Resources[$resourceName] = $newValue
Write-Debug "Scaled $resourceName from original $originalValue to $newValue (factor: $ScaleFactor)"
}
}
catch {
@@ -80,8 +79,4 @@ function Invoke-WinUtilFontScaling {
$percentage = [math]::Round($ScaleFactor * 100)
$sync.FontScalingValue.Text = "$percentage%"
}
Write-Debug "Font scaling applied with factor: $ScaleFactor"
}
+7 -23
View File
@@ -21,8 +21,7 @@ function Invoke-WinUtilTweaks {
$KeepServiceStartup = $true
)
Write-Debug "Tweaks: $($CheckBox)"
if($undo) {
if ($undo) {
$Values = @{
Registry = "OriginalValue"
Service = "OriginalType"
@@ -37,18 +36,16 @@ function Invoke-WinUtilTweaks {
ScriptType = "InvokeScript"
}
}
if($sync.configs.tweaks.$CheckBox.service) {
Write-Debug "KeepServiceStartup is $KeepServiceStartup"
if ($sync.configs.tweaks.$CheckBox.service) {
$sync.configs.tweaks.$CheckBox.service | ForEach-Object {
$changeservice = $true
# The check for !($undo) is required, without it the script will throw an error for accessing unavailable member, which's the 'OriginalService' Property
if($KeepServiceStartup -AND !($undo)) {
if ($KeepServiceStartup -AND !($undo)) {
try {
# Check if the service exists
$service = Get-Service -Name $psitem.Name -ErrorAction Stop
if(!($service.StartType.ToString() -eq $psitem.$($values.OriginalService))) {
Write-Debug "Service $($service.Name) was changed in the past to $($service.StartType.ToString()) from it's original type of $($psitem.$($values.OriginalService)), will not change it to $($psitem.$($values.service))"
$changeservice = $false
}
} catch [System.ServiceProcess.ServiceNotFoundException] {
@@ -56,41 +53,28 @@ function Invoke-WinUtilTweaks {
}
}
if($changeservice) {
Write-Debug "$($psitem.Name) and state is $($psitem.$($values.service))"
if ($changeservice) {
Set-WinUtilService -Name $psitem.Name -StartupType $psitem.$($values.Service)
}
}
}
if($sync.configs.tweaks.$CheckBox.registry) {
if ($sync.configs.tweaks.$CheckBox.registry) {
$sync.configs.tweaks.$CheckBox.registry | ForEach-Object {
Write-Debug "$($psitem.Name) and state is $($psitem.$($values.registry))"
if (($psitem.Path -imatch "hku") -and !(Get-PSDrive -Name HKU -ErrorAction SilentlyContinue)) {
$null = (New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS)
if (Get-PSDrive -Name HKU -ErrorAction SilentlyContinue) {
Write-Debug "HKU drive created successfully."
} else {
Write-Debug "Failed to create HKU drive."
}
}
Set-WinUtilRegistry -Name $psitem.Name -Path $psitem.Path -Type $psitem.Type -Value $psitem.$($values.registry)
}
}
if($sync.configs.tweaks.$CheckBox.$($values.ScriptType)) {
if ($sync.configs.tweaks.$CheckBox.$($values.ScriptType)) {
$sync.configs.tweaks.$CheckBox.$($values.ScriptType) | ForEach-Object {
Write-Debug "$($psitem) and state is $($psitem.$($values.ScriptType))"
$Scriptblock = [scriptblock]::Create($psitem)
Invoke-WinUtilScript -ScriptBlock $scriptblock -Name $CheckBox
}
}
if(!$undo) {
if (!$undo) {
if($sync.configs.tweaks.$CheckBox.appx) {
$sync.configs.tweaks.$CheckBox.appx | ForEach-Object {
Write-Debug "UNDO $($psitem.Name)"
Remove-WinUtilAPPX -Name $psitem
}
}
}
}
-11
View File
@@ -23,14 +23,6 @@ function Reset-WPFCheckBoxes {
$CheckBoxesToCheck = $sync.selectedApps + $sync.selectedTweaks + $sync.selectedFeatures
$CheckBoxes = ($sync.GetEnumerator()).where{ $_.Value -is [System.Windows.Controls.CheckBox] -and $_.Name -notlike "WPFToggle*" -and $_.Name -like "$checkboxfilterpattern"}
Write-Debug "Getting checkboxes to set, number of checkboxes: $($CheckBoxes.Count)"
if ($CheckBoxesToCheck -ne "") {
$debugMsg = "CheckBoxes to Check are: "
$CheckBoxesToCheck | ForEach-Object { $debugMsg += "$_, " }
$debugMsg = $debugMsg -replace (',\s*$', '')
Write-Debug "$debugMsg"
}
foreach ($CheckBox in $CheckBoxes) {
$checkboxName = $CheckBox.Key
@@ -43,11 +35,9 @@ function Reset-WPFCheckBoxes {
if ($CheckBoxesToCheck -contains $checkboxName) {
# If it exists, set IsChecked to true
$sync.$checkboxName.IsChecked = $true
Write-Debug "$checkboxName is checked"
} else {
# If it doesn't exist, set IsChecked to false
$sync.$checkboxName.IsChecked = $false
Write-Debug "$checkboxName is not checked"
}
}
@@ -68,7 +58,6 @@ function Reset-WPFCheckBoxes {
foreach ($toggle in $allToggles) {
if ($importedToggles -contains $toggle.Key) {
$sync[$toggle.Key].IsChecked = $true
Write-Debug "Restoring toggle: $($toggle.Key) = checked"
}
# Toggles not present in the import are intentionally left untouched;
# their current UI state already reflects the real system state.
-2
View File
@@ -34,7 +34,6 @@ function Set-Preferences{
$ini = ""
foreach($key in $sync.preferences.Keys) {
$pref = "$($key)=$($sync.preferences.$key)"
Write-Debug "Saving pref: $($pref)"
$ini = $ini + $pref + "`r`n"
}
$ini | Out-File $iniPath
@@ -49,7 +48,6 @@ function Set-Preferences{
$arr = $line -split "=",-2
$key = $arr[0] -replace "\s",""
$value = $arr[1] -replace "\s",""
Write-Debug "Preference: Key = '$($key)' Value ='$($value)'"
$sync.preferences.$key = $value
}
}
@@ -12,8 +12,6 @@ function Update-WinUtilSelections {
$flatJson
)
Write-Debug "JSON to import: $($flatJson)"
foreach ($item in $flatJson) {
# Ensure each item is treated as a string to handle PSCustomObject from JSON deserialization
$cbkey = [string]$item
@@ -51,11 +49,4 @@ function Update-WinUtilSelections {
}
}
}
Write-Debug "-------------------------------------"
Write-Debug "Selected Apps: $($sync.selectedApps)"
Write-Debug "Selected Tweaks: $($sync.selectedTweaks)"
Write-Debug "Selected Toggles: $($sync.selectedToggles)"
Write-Debug "Selected Features: $($sync.selectedFeatures)"
Write-Debug "--------------------------------------"
}
@@ -85,11 +85,4 @@ function Invoke-WPFSelectedCheckboxesUpdate{
Write-Host "Unknown group for checkbox: $($appKey)"
}
}
Write-Debug "-------------------------------------"
Write-Debug "Selected Apps: $($sync.selectedApps)"
Write-Debug "Selected Tweaks: $($sync.selectedTweaks)"
Write-Debug "Selected Toggles: $($sync.selectedToggles)"
Write-Debug "Selected Features: $($sync.selectedFeatures)"
Write-Debug "--------------------------------------"
}
@@ -29,8 +29,6 @@ function Invoke-WPFtweaksbutton {
return
}
Write-Debug "Number of tweaks to process: $($Tweaks.Count)"
if ($restorePointSelected) {
$sync.ProcessRunning = $true
@@ -58,7 +56,6 @@ function Invoke-WPFtweaksbutton {
# The leading "," in the ParameterList is necessary because we only provide one argument and powershell cannot be convinced that we want a nested loop with only one argument otherwise
$handle = Invoke-WPFRunspace -ParameterList @(("tweaks", $tweaksToRun), ("dnsProvider", $dnsProvider), ("completedSteps", $completedSteps), ("totalSteps", $totalSteps)) -ScriptBlock {
param($tweaks, $dnsProvider, $completedSteps, $totalSteps)
Write-Debug "Inside Number of tweaks to process: $($Tweaks.Count)"
$sync.ProcessRunning = $true