From 775ad8d862b06d7fafa41ea60f29bb6816072f14 Mon Sep 17 00:00:00 2001 From: Jeffrey <9938813+Raphire@users.noreply.github.com> Date: Sat, 18 Jul 2026 21:24:15 +0200 Subject: [PATCH] Add missing docstrings --- Scripts/Features/InvokeChanges.ps1 | 20 ++++-- .../Features/RestoreRegistryApplyState.ps1 | 61 +++++++++++++++++++ Scripts/FileIO/LoadAppsDetailsFromJson.ps1 | 24 +++++++- 3 files changed, 100 insertions(+), 5 deletions(-) diff --git a/Scripts/Features/InvokeChanges.ps1 b/Scripts/Features/InvokeChanges.ps1 index 58bf0b3..a23f425 100644 --- a/Scripts/Features/InvokeChanges.ps1 +++ b/Scripts/Features/InvokeChanges.ps1 @@ -9,10 +9,6 @@ - Custom logic: app removal, Windows optional features, start menu replacement, and other special-case features. #> -function Test-RunningAsSystem { - return ([Security.Principal.WindowsIdentity]::GetCurrent().User.Value -eq 'S-1-5-18') -} - function Invoke-FeatureApply { param( [Parameter(Mandatory)] @@ -433,3 +429,19 @@ function Invoke-AllChanges { Write-Host "$($script:RegistryImportFailures) registry import change(s) failed. See output above for details." -ForegroundColor Yellow } } + +<# + .SYNOPSIS + Tests whether Win11Debloat is running under the SYSTEM account. + + .DESCRIPTION + Compares the current Windows identity's security identifier (SID) with + the well-known Local System SID (S-1-5-18). + + .OUTPUTS + System.Boolean + Returns $true when the current process runs as SYSTEM; otherwise, $false. +#> +function Test-RunningAsSystem { + return ([Security.Principal.WindowsIdentity]::GetCurrent().User.Value -eq 'S-1-5-18') +} diff --git a/Scripts/Features/RestoreRegistryApplyState.ps1 b/Scripts/Features/RestoreRegistryApplyState.ps1 index b5ef489..5cf323d 100644 --- a/Scripts/Features/RestoreRegistryApplyState.ps1 +++ b/Scripts/Features/RestoreRegistryApplyState.ps1 @@ -1,3 +1,16 @@ +<# + .SYNOPSIS + Runs a script block against the registry hive for a backup target. + + .PARAMETER Target + A supported backup target: DefaultUserProfile or User:. + + .PARAMETER ScriptBlock + The operation to run after the target user hive is available. + + .PARAMETER ArgumentObject + Optional object passed to the script block. +#> function Invoke-WithLoadedRestoreHive { param( [Parameter(Mandatory)] @@ -24,6 +37,13 @@ function Invoke-WithLoadedRestoreHive { Invoke-WithTargetUserHive -TargetUserName $targetUserName -ScriptBlock $ScriptBlock -ArgumentObject $ArgumentObject } +<# + .SYNOPSIS + Restores a registry key and its child keys from a backup snapshot. + + .PARAMETER Snapshot + The saved registry-key state, including existence, values, and subkeys. +#> function Restore-RegistryKeySnapshot { param( [Parameter(Mandatory)] @@ -74,6 +94,16 @@ function Restore-RegistryKeySnapshot { } } +<# + .SYNOPSIS + Restores or removes a registry value from a backup snapshot. + + .PARAMETER RegistryKey + The open registry key that contains the value. + + .PARAMETER Snapshot + The saved registry-value state to apply. +#> function Restore-RegistryValueSnapshot { param( [Parameter(Mandatory)] @@ -105,6 +135,16 @@ function Restore-RegistryValueSnapshot { } } +<# + .SYNOPSIS + Converts a backed-up registry value-kind name to its .NET enum value. + + .PARAMETER KindName + The registry value-kind name stored in the backup. + + .OUTPUTS + Microsoft.Win32.RegistryValueKind +#> function Convert-RegistryValueKindFromBackup { param( [string]$KindName @@ -122,6 +162,16 @@ function Convert-RegistryValueKindFromBackup { } } +<# + .SYNOPSIS + Converts backed-up data to a value suitable for registry restoration. + + .PARAMETER Kind + The registry value kind that determines how the data is converted. + + .PARAMETER Data + The serialized value data from the backup. +#> function Convert-RegistryValueDataFromBackup { param( [Microsoft.Win32.RegistryValueKind]$Kind, @@ -162,6 +212,17 @@ function Convert-RegistryValueDataFromBackup { } } +<# + .SYNOPSIS + Converts serialized binary backup data to a byte array. + + .PARAMETER Data + A byte array or collection of integer byte values from the backup. + + .OUTPUTS + System.Byte[] + Returns $null when the input contains invalid byte data. +#> function Convert-BackupDataToByteArray { param( $Data diff --git a/Scripts/FileIO/LoadAppsDetailsFromJson.ps1 b/Scripts/FileIO/LoadAppsDetailsFromJson.ps1 index bb0b99c..0fa397b 100644 --- a/Scripts/FileIO/LoadAppsDetailsFromJson.ps1 +++ b/Scripts/FileIO/LoadAppsDetailsFromJson.ps1 @@ -1,4 +1,26 @@ -# Read Apps.json and return list of app objects with optional filtering +<# + .SYNOPSIS + Loads application details from Apps.json. + + .DESCRIPTION + Reads the application definitions from Apps.json, optionally filters the + results to installed applications, and returns normalized app objects for + display and selection. + + .PARAMETER OnlyInstalled + Filters the results to applications detected through Appx or the supplied + winget installation list. + + .PARAMETER InstalledList + A pre-fetched winget installation list used when filtering installed apps. + + .PARAMETER InitialCheckedFromJson + Sets each returned app's IsChecked value from its SelectedByDefault setting. + + .OUTPUTS + System.Management.Automation.PSCustomObject[] + Application detail objects containing display, selection, and removal data. +#> function LoadAppsDetailsFromJson { param ( [switch]$OnlyInstalled,