Capturing Proxy Errors for Powershell connector
Hello,
I'm fairly new to this so I'm hoping I'm just missing something simple here. What are the best practices for working with Powershell connector errors that come from "Proxy Error: System.Management.Automation.RemoteException". Normally with try/catch I've been referencing the '$_' object or something more specific under Exception and mapping that to a Write-Output variable used later in the flow. However when working with commands that create another session such as Connect-ExchangeOnline this works differently.
How does one go about outputting the error that comes back in Test Results as a Proxy Error within a flow?
Thanks!
Answer (1)
Hi William,
There might be an answer for your problem: getting access to errors in remote PS (Exchange). It's described best in this link. The answer might be to wrap the call using Invoke-Command
and passing parameters using -ArgumentList
. This should allow you to try/catch
the errors produced. I haven't tested this, but as an example you could try:
try {
Invoke-Command
-Session $ses
-ScriptBlock { Get-Mailbox $args[0] }
-ArgumentList $UserUPN
-ErrorAction Stop
Write-Output $true
Write-Output ("Success")
}
catch {
Write-Output $false
Write-Host ("Error occurred")
}
There appears to be a way through Event Notifications to monitor flow events and get the error messages but is that possible through the flow itself? - William Fricke Tue 9/20/22 2:55 PM