Enhance output documentation and error handling

This commit is contained in:
Jeffrey
2026-08-22 17:14:09 +02:00
parent 80eadd531c
commit c921730703
17 changed files with 228 additions and 66 deletions
+7 -1
View File
@@ -1,4 +1,10 @@
# Import & execute regfile
<#
.SYNOPSIS
Imports and executes a registry file.
.OUTPUTS
System.Boolean. $true when the registry file is applied or previewed successfully; otherwise $false.
#>
function Import-RegistryFile {
param (
$message,
+6 -3
View File
@@ -198,11 +198,11 @@ function Invoke-FeatureUndo {
return $false
}
'EnableWindowsSandbox' {
Write-Host "> $($feature.ApplyUndoText)..."
Write-Host "> $undoText..."
return (Disable-WindowsFeature 'Containers-DisposableClientVM')
}
'EnableWindowsSubsystemForLinux' {
Write-Host "> $($feature.ApplyUndoText)..."
Write-Host "> $undoText..."
if (-not (Disable-WindowsFeature 'Microsoft-Windows-Subsystem-Linux')) { return $false }
return (Disable-WindowsFeature 'VirtualMachinePlatform')
}
@@ -271,7 +271,10 @@ function Invoke-ApplyFeatures {
& $script:ApplyProgressCallback $step $TotalSteps $displayName
}
if (-not (Invoke-FeatureApply -FeatureId $featureId)) {
# Compare app-removal failure counts so a feature that only fails due to
# app removal isn't also double-reported as a feature failure.
$appRemovalFailuresBefore = $script:AppRemovalFailures
if ((-not (Invoke-FeatureApply -FeatureId $featureId)) -and ($script:AppRemovalFailures -eq $appRemovalFailuresBefore)) {
$script:FeatureFailures++
}
Write-Host ""
@@ -1,3 +1,10 @@
<#
.SYNOPSIS
Creates a system restore point.
.OUTPUTS
System.Boolean. $true when a restore point is created; otherwise $false.
#>
function Invoke-SystemRestorePoint {
$failed = $false
$isSilent = ($script:Params -and $script:Params.ContainsKey('Silent')) -or $script:Silent
+6
View File
@@ -18,6 +18,9 @@
.EXAMPLE
Replace-StartMenuForAllUsers -startMenuTemplate "C:\CustomLayout.bin"
.OUTPUTS
System.Boolean. $true when all resolved profiles are updated or the change is previewed; otherwise $false.
#>
function Replace-StartMenuForAllUsers {
param (
@@ -99,6 +102,9 @@ function Replace-StartMenuForAllUsers {
.EXAMPLE
Replace-StartMenu -startMenuBinFile "$env:LOCALAPPDATA\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState\start2.bin" -startMenuTemplate "C:\CustomLayout.bin"
.OUTPUTS
System.Boolean. $true when the template is valid and copied, or the change is previewed; otherwise $false.
#>
function Replace-StartMenu {
param (
@@ -10,6 +10,9 @@
.EXAMPLE
DisableStoreSearchSuggestionsForAllUsers
.OUTPUTS
System.Boolean. $true when a profile is processed and all ACL changes succeed; otherwise $false.
#>
function Set-StoreSearchSuggestionsDisabledForAllUsers {
$success = $true
@@ -60,6 +63,9 @@ function Set-StoreSearchSuggestionsDisabledForAllUsers {
.EXAMPLE
DisableStoreSearchSuggestions -StoreAppsDatabase "$env:LOCALAPPDATA\Packages\Microsoft.WindowsStore_8wekyb3d8bbwe\LocalState\store.db"
.OUTPUTS
System.Boolean. $true when the database ACL is restricted or previewed; otherwise $false.
#>
function Set-StoreSearchSuggestionsDisabled {
param (
@@ -115,6 +121,9 @@ function Set-StoreSearchSuggestionsDisabled {
.EXAMPLE
EnableStoreSearchSuggestionsForAllUsers
.OUTPUTS
System.Boolean. $true when a profile is processed and all ACL changes succeed; otherwise $false.
#>
function Set-StoreSearchSuggestionsEnabledForAllUsers {
$success = $true
@@ -164,6 +173,9 @@ function Set-StoreSearchSuggestionsEnabledForAllUsers {
.EXAMPLE
EnableStoreSearchSuggestions -StoreAppsDatabase "$env:LOCALAPPDATA\Packages\Microsoft.WindowsStore_8wekyb3d8bbwe\LocalState\store.db"
.OUTPUTS
System.Boolean. $true when the deny ACL is removed, the database is absent, or the change is previewed; otherwise $false.
#>
function Set-StoreSearchSuggestionsEnabled {
param (
@@ -34,6 +34,9 @@ function Get-TelemetryScheduledTasks {
.EXAMPLE
Disable-TelemetryScheduledTasks
.OUTPUTS
System.Boolean. $true when every task is disabled, absent, already disabled, or previewed; otherwise $false.
#>
function Disable-TelemetryScheduledTasks {
Write-Host "> Disabling telemetry scheduled tasks..."
@@ -97,6 +100,9 @@ function Disable-TelemetryScheduledTasks {
.EXAMPLE
Enable-TelemetryScheduledTasks
.OUTPUTS
System.Boolean. $true when every task is enabled, absent, already enabled, or previewed; otherwise $false.
#>
function Enable-TelemetryScheduledTasks {
Write-Host "> Enabling telemetry scheduled tasks..."
+14 -2
View File
@@ -1,4 +1,10 @@
# Enables a Windows optional feature and pipes its output to the console
<#
.SYNOPSIS
Enables a Windows optional feature and pipes its output to the console.
.OUTPUTS
System.Boolean. $true when enabling succeeds or is previewed; otherwise $false.
#>
function Enable-WindowsFeature {
param (
[string]$FeatureName
@@ -44,7 +50,13 @@ function Enable-WindowsFeature {
return $true
}
# Disables a Windows optional feature and pipes its output to the console
<#
.SYNOPSIS
Disables a Windows optional feature and pipes its output to the console.
.OUTPUTS
System.Boolean. $true when disabling succeeds or is previewed; otherwise $false.
#>
function Disable-WindowsFeature {
param (
[string]$FeatureName