mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-05-10 00:02:09 +00:00
Remove debug switches to minimize clutter and shorten the code
This commit is contained in:
parent
ab97c776f9
commit
1abf96e79d
@ -16,22 +16,10 @@ function Invoke-WPFSystemRepair {
|
|||||||
Runs chkdsk on the system drive
|
Runs chkdsk on the system drive
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Chkdsk /Scan - Runs an online scan on the system drive, attempts to fix any corruption, and queues other corruption for fixing on reboot
|
Chkdsk /Scan - Runs an online scan on the system drive, attempts to fix any corruption, and queues other corruption for fixing on reboot
|
||||||
.PARAMETER verbose
|
|
||||||
If specified, print output from chkdsk
|
|
||||||
.NOTES
|
|
||||||
VerbosePreference is set locally within a script block (& { ... }) to avoid affecting the global or parent scope.
|
|
||||||
#>
|
#>
|
||||||
param(
|
param(
|
||||||
[switch]$verbose,
|
|
||||||
[int]$parentProgressId = 0
|
[int]$parentProgressId = 0
|
||||||
)
|
)
|
||||||
& {
|
|
||||||
if ($verbose) {
|
|
||||||
$VerbosePreference = "Continue"
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$VerbosePreference = "SilentlyContinue"
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Progress -Id 1 -ParentId $parentProgressId -Activity $childProgressBarActivity -Status "Running chkdsk..." -PercentComplete 0
|
Write-Progress -Id 1 -ParentId $parentProgressId -Activity $childProgressBarActivity -Status "Running chkdsk..." -PercentComplete 0
|
||||||
$oldpercent = 0
|
$oldpercent = 0
|
||||||
@ -49,7 +37,6 @@ function Invoke-WPFSystemRepair {
|
|||||||
}
|
}
|
||||||
Write-Progress -Id 1 -Activity $childProgressBarActivity -Status "chkdsk Completed" -PercentComplete 100 -Completed
|
Write-Progress -Id 1 -Activity $childProgressBarActivity -Status "chkdsk Completed" -PercentComplete 100 -Completed
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function Invoke-SFC {
|
function Invoke-SFC {
|
||||||
<#
|
<#
|
||||||
@ -57,25 +44,15 @@ function Invoke-WPFSystemRepair {
|
|||||||
Runs sfc on the system drive
|
Runs sfc on the system drive
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
SFC /ScanNow - Performs a scan of the system files and fixes any corruption
|
SFC /ScanNow - Performs a scan of the system files and fixes any corruption
|
||||||
.PARAMETER verbose
|
|
||||||
If specified, print output from sfc
|
|
||||||
.NOTES
|
.NOTES
|
||||||
VerbosePreference and ErrorActionPreference are set locally within a script block to isolate their effects. ErrorActionPreference suppresses false errors caused by sfc.exe output redirection.
|
ErrorActionPreference is set locally within a script block & {...} to isolate their effects.
|
||||||
|
ErrorActionPreference suppresses false errors caused by sfc.exe output redirection.
|
||||||
A bug in SFC output buffering causes progress updates to appear in chunks when redirecting output
|
A bug in SFC output buffering causes progress updates to appear in chunks when redirecting output
|
||||||
|
|
||||||
#>
|
#>
|
||||||
param(
|
param(
|
||||||
[switch]$verbose,
|
|
||||||
[int]$parentProgressId = 0
|
[int]$parentProgressId = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
& {
|
& {
|
||||||
if ($verbose) {
|
|
||||||
$VerbosePreference = "Continue"
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$VerbosePreference = "SilentlyContinue"
|
|
||||||
}
|
|
||||||
$ErrorActionPreference = "SilentlyContinue"
|
$ErrorActionPreference = "SilentlyContinue"
|
||||||
Write-Progress -Id 1 -ParentId $parentProgressId -Activity $childProgressBarActivity -Status "Running SFC..." -PercentComplete 0
|
Write-Progress -Id 1 -ParentId $parentProgressId -Activity $childProgressBarActivity -Status "Running SFC..." -PercentComplete 0
|
||||||
$oldpercent = 0
|
$oldpercent = 0
|
||||||
@ -106,29 +83,14 @@ function Invoke-WPFSystemRepair {
|
|||||||
/Online - Fixes the currently running system image
|
/Online - Fixes the currently running system image
|
||||||
/Cleanup-Image - Performs cleanup operations on the image, could remove some unneeded temporary files
|
/Cleanup-Image - Performs cleanup operations on the image, could remove some unneeded temporary files
|
||||||
/Restorehealth - Performs a scan of the image and fixes any corruption
|
/Restorehealth - Performs a scan of the image and fixes any corruption
|
||||||
|
|
||||||
.PARAMETER verbose
|
|
||||||
If specified, print output from DISM
|
|
||||||
.NOTES
|
|
||||||
VerbosePreference is set locally within a script block (& { ... }) to avoid affecting the global or parent scope.
|
|
||||||
#>
|
#>
|
||||||
param(
|
param(
|
||||||
[switch]$verbose,
|
|
||||||
[int]$parentProgressId = 0
|
[int]$parentProgressId = 0
|
||||||
)
|
)
|
||||||
& {
|
|
||||||
if ($verbose) {
|
|
||||||
$VerbosePreference = "Continue"
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$VerbosePreference = "SilentlyContinue"
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Progress -Id 1 -ParentId $parentProgressId -Activity $childProgressBarActivity -Status "Running DISM..." -PercentComplete 0
|
Write-Progress -Id 1 -ParentId $parentProgressId -Activity $childProgressBarActivity -Status "Running DISM..." -PercentComplete 0
|
||||||
$oldpercent = 0
|
$oldpercent = 0
|
||||||
DISM /Online /Cleanup-Image /RestoreHealth | ForEach-Object {
|
DISM /Online /Cleanup-Image /RestoreHealth | ForEach-Object {
|
||||||
Write-Verbose $_
|
Write-Verbose $_
|
||||||
|
|
||||||
# Filter for lines that contain a percentage that is greater than the previous one
|
# Filter for lines that contain a percentage that is greater than the previous one
|
||||||
if ($_ -match "(\d+)[.,]\d+%") {
|
if ($_ -match "(\d+)[.,]\d+%") {
|
||||||
[int]$percent = $matches[1]
|
[int]$percent = $matches[1]
|
||||||
@ -141,7 +103,6 @@ function Invoke-WPFSystemRepair {
|
|||||||
}
|
}
|
||||||
Write-Progress -Id 1 -Activity $childProgressBarActivity -Status "DISM Completed" -PercentComplete 100 -Completed
|
Write-Progress -Id 1 -Activity $childProgressBarActivity -Status "DISM Completed" -PercentComplete 100 -Completed
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$childProgressBarActivity = "Scanning for corruption"
|
$childProgressBarActivity = "Scanning for corruption"
|
||||||
Write-Progress -Id 0 -Activity "Repairing Windows" -PercentComplete 0
|
Write-Progress -Id 0 -Activity "Repairing Windows" -PercentComplete 0
|
||||||
|
Loading…
Reference in New Issue
Block a user