How would One allow users to "Pause the current Pipeline and return to the command prompt" and later resume in a powershell script?
I stumbled upon this line in a blog post about User Interaction in Powershell
$suspend = New-Object System.Management.Automation.Host.ChoiceDescription "&Suspend", "Pause the current pipeline and return to the command prompt. Type ""exit"" to resume the pipeline."
It was a mock option in a prompt imitating the appearance of a native command (Remove-Item). Lo and behold: That command actually Implements that behavior. Doing a quick Google Search, I did not find an implementation in a script.
You can use
$Host.EnterNestedPrompt()to suspend the current operation to enter a "nested" prompt - execution will resume once you exit it (using eitherexitor$Host.ExitNestedPrompt()):Now try invoking the function with and without the
-Interveneswitch: