Remix.run Logo
jve 3 days ago

Actually great intro for step-by-step powershell scripting.

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...

TacticalMalice 3 days ago | parent [-]

Throw-And-Exit is a custom function in the script @ https://github.com/brooks-code/WSL-VHDX-Compact/blob/main/ws...

jve 3 days ago | parent [-]

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.

twilight-code 2 days ago | parent [-]

good point