How can I write to standard error from PowerShell, or trap errors such that:
I needed to solve this problem myself recently so I put together a Write-ErrorMessage function as detailed here: https://intellitect.com/powershell-write-error-without-writing-stack-trace/
Specifically, I leveraged the combination
Write-Error -Message $err -ErrorAction SilentlyContinue
$Host.UI.WriteErrorLine($errorMessage)