Re:Free up space (effortlessly) on WSL2
by TacticalMalice on Tuesday August 19, 2025 @04:25AM
(#44949484)
Throw-And-Exit is a custom function in the script @ https://github.com/brooks-code/WSL-VHDX-Compact/blob/main/ws...
Well in that case, a regular throw can be used. Don't see a need for custom function. From docs:
> The throw keyword causes a terminating error. You can use the throw keyword to stop the processing of a command, function, or script.
Re:Free up space (effortlessly) on WSL2
by twilight-code on Tuesday August 19, 2025 @02:21PM
(#44954587)
good point
I thought I didn't know about "Throw-And-Exit" command, but no, my powershell doesn't have that and google also doesn't know a thing, so wonder what's up with that.
And instead of manual confirmations, one can write script with ShouldProcess support to have support for builtin -Confirm/-WhatIf/-Force parameters. And it would actually be a great use case for that scheduled task to run with -Force parameter instead of changing code to strip out confirmations. https://learn.microsoft.com/en-us/powershell/scripting/learn...