Hi Support,
Quick question, and it might be a simple answer I'm missing.
I've got a few Powershell scripts that look something like this:
if ("$Date" -eq "{DATENOWADD(Days|-2|yyyyMMdd)}") {
Write-Output "DC_Inv_{DATENOWADD(Days|-1|yyyyMMdd)}_*.csv"} else {
Write-Error "Kevin"}
On my servers on VC 7.1.4, the task errors, and the Error Output field contains only the text I specify ("Kevin" in this example).
But it seems like on VC 7.6.4, the task does not error. It is successful with "No Output" unless I specify -ErrorAction Stop
I understand that Write-Error is a non-terminating error, however, adding -ErrorAction Stop adds a whole bunch of other stuff into the error output:
ExecuteProcess("D:\Program Files\Decisions Made Easy\Visual Cron7\\TaskPowerShell.exe" 3751)->System.Management.Automation.ActionPreferenceStopException: Command execution stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Anand
at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at System.Management.Automation.Runspaces.Pipeline.Invoke()
at TaskPowerShell.PowerShellTaskClass.Run(ProcessPowerShellTaskInfoClass ti, StringBuilder& sbResultObject)
Exception in Task: ExecuteProcess("D:\Program Files\Decisions Made Easy\Visual Cron7\\TaskPowerShell.exe" 3751)->System.Management.Automation.ActionPreferenceStopException: Command execution stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Kevin
at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at System.Management.Automation.Runspaces.Pipeline.Invoke()
at TaskPowerShell.PowerShellTaskClass.Run(ProcessPowerShellTaskInfoClass ti, StringBuilder& sbResultObject)
The simple question is: In new versions of VC, how can I cause a Powershell task to fail and write the error output with only the text I specify, instead of all the other built-in PS error text?
Thanks!