← Docs home

Support Force Parameter for Interactive Sessions

📐 Rule.

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.

Interactive host methods that Force overrides.

Implemented by an interactive host on System.Management.Automation.Host.PSHostUserInterface and a related interface:

Why.

A non-interactive host has no one to answer a prompt. Without Force, the cmdlet stalls or fails when scripted.