Active IQ Unified Manager Discussions

Remove Error Output

MATTHEWKOOSWN
5,233 Views

Hi There,

 

I have a workflow command step that actually works and completes all the required actions of that command step but throws the following error causing the step to show up as failed in the workflow and not continuing.  The command step uses invoke-command to launch a batch file that uses psexec to launch a powershell script remotely on another server.  

 

The error is:

 

System.Management.Automation.RemoteException

 

I just want that error to go away so the command step shows as completed successfully and continues on, especially since it really did complete its required action successfully.  I've tried redirecting to null with 2>$null and also | Out-Null and also a try catch block that doesn't throw the error execption message.

 

I understand that powershell invoke-command and pssession allows me to execute powershell commands remotely however I have tried numerous times to make it work that way without any success, it seems to need an actual logged in session before executing the powershell script and psexec has been the only way I've been able to make it work.

 

Thanks,

Matt.

 

 

4 REPLIES 4

sinhaa
5,202 Views

@MATTHEWKOOSWN

 

Matt,

 

Without looking at the code, its difficult to point why is this error thrown. If you are sure that despite this error exception, your tasks get done,  and its only a matter of ignoring this exception you can try to use  -ErrorAction SilentlyContinue on the Invoke-Command

 

If this doesn't resolve it, the code would need to be debugged to remove the root cause.

 

sinhaa

 

 

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

MATTHEWKOOSWN
5,178 Views

Thanks Abhishek,

 

I tried the silently continue route as well and it still errors out with the same error message.  The code is below, the error gets generated by the Invoke-Command from the ScriptBlock.  Do you have any other suggestions I could try?

 

 

$pass=ConvertFromSecureToPlain -SecurePassword $UserCreds.Password
$username=$UserCreds.Username

try
{
$resultObj = Invoke-Command -ScriptBlock {try{c:\varonis.bat $fileserverid $sharename $username $pass}catch{}} -ErrorAction SilentlyContinue | Out-Null
}
catch
{
$result = "${resultObj.ToString()}${warnMsg}${errorMsg}" + $_.Exception.Message;
#throw $result
}

 

The varonis.bat file that the scriptblock is calling is as follows:

 

c:\windows\system32\psexec.exe \\hovaraspdm01 /accepteula /u %3 /p %4 cmd /c "START /WAIT Powershell c:\AddShareToVaronis.ps1 -fileserverid %1 -sharename %2"

sinhaa
5,138 Views

@MATTHEWKOOSWN

 

 

I'll have the rest of the discussion on email. Later I'll post my conclusion on this thread for other to see.

 

sinhaa

 

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

FelipeMafra
4,993 Views

Hi ,

 

Just to clarify Powershell only enters in a catch block after a try error, so you should use -ErrorAction Stop, otherwise it will simply crash, not executing catch block.

 

Second point is that Powershell have a problem with double hop.

 

Take a look at this article if you want to understand it: https://blogs.technet.microsoft.com/heyscriptingguy/2013/04/04/enabling-multihop-remoting/

 

 

Public