Search code examples
powershellgrpcurl

How to stop the errors in grpcurl within PowerShell script


I used grpcurl command line tool for grpc requests. I include my grpc requests in PowerShell script.

when some requests have a failure statue PowerShell script will throw errors.

I want to block the errors from being shown in script's output.

I tried -ErrorAction Stop and Try/Catch methods but it doesn't work with grpc request.

here an example of my grpc request within the PowerShell script.

$GetParameters = grpcurl -plaintext -import-path <path> -proto service.proto <IP>:<port> descriptors./GetParameters 

Solution

  • This is how to hide errors of external commands. '2' is 'standard error'.

    grpcurl 2>$null