When writing PowerShell scripts, I noticed when certain cmdlets encounter problems they bring up an interactive prompt, Remove-Item on a non-empty directory being an example. This is deadly when attempting to automate tasks, I'd much rather the action just fail and either throw an exception or return a bad return code so that the entire script isn't locked up waiting for a response.
Is there any way to force PowerShell to automatically fail as opposed to seeking user input on actions?
Remove-Item
fail fast?"