0

Ignoring an errorlevel != 0 in Windows PowerShell (ISE)

I have read this link but not sure how to run "Invoke-Command" my $ErrorActionPreference is "continue".

This is the error I am getting :

06:06:55  + & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command '& ''E: ...
06:06:55  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
06:06:55      + CategoryInfo          : NotSpecified: (root : 2020-10-...something:String) [], RemoteException
06:06:55      + FullyQualifiedErrorId : NativeCommandError

1 Answer 1

0

The $errorActionPreference should be defined inside the scriptblock like:

Invoke-Command {$ErrorActionPreference = 'SilentlyContinue'; REST OF THE CODE}
Sign up to request clarification or add additional context in comments.

1 Comment

how this will run on Jenkins descriptive style "Jenkinsfile", I have used this: powershell (Invoke-Command {$ErrorActionPreference = 'SilentlyContinue'; "my code" }) This gives me error : hudson.remoting.ProxyException: groovy.lang.MissingPropertyException: No such property: Invoke for class: WorkflowScript 07:39:35 at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53) 07:39:35 at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:458) at org.kohsuke.groovy.sandbox.impl.Checker$7.call(Checker.java:355)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.