If your cmdlet runs interactively, always provide a Force parameter that overrides the interactive actions such as prompts and reading lines of input. This lets the cmdlet run in non-interactive scripts and hosts.
Implemented by an interactive host on System.Management.Automation.Host.PSHostUserInterface and a related interface:
PromptPromptForChoiceIHostUISupportsMultipleChoiceSelection.PromptForChoicePromptForCredentialReadLineReadLineAsSecureStringA non-interactive host has no one to answer a prompt. Without Force, the cmdlet stalls or fails when scripted.