I run this command to backup a database to a network path.
Invoke-ASCmd -Server $ASServer -Query ($ASBackupQry.Replace('$(Database)', $Database))
I know the path does not exist and will trigger the an error
<return xmlns="urn:schemas-microsoft-com:xml-analysis"><root xmlns="urn:schemas-microsoft-com:xml-analysis:empty"><Exception xmlns="urn:schemas-microsoft-com:xml-analysis:exception"
/><Messages xmlns="urn:schemas-microsoft-com:xml-analysis:exception"><Error ErrorCode="-1056833536" Description="File system error: The following error occurred during a file operation: An unexpected network error
occurred. . (networkpath.abf)." Source="Microsoft SQL Server 2016 Analysis Services" HelpFile="" /></Messages></root></return>
I run this in a try/catch, but it does not trigger the catch. $ErrorActionPreference is set to stop. My work around is to send the output to a string object and then search for exception and trigger the catch manually.
Am I doing something wrong?