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
Theo
  • 57,719
  • 8
  • 24
  • 41
DarcyM
  • 9
  • 1
  • 5

1 Answers1

0

The $errorActionPreference should be defined inside the scriptblock like:

Invoke-Command {$ErrorActionPreference = 'SilentlyContinue'; REST OF THE CODE}
Wasif
  • 14,755
  • 3
  • 14
  • 34
  • 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) – DarcyM Oct 17 '20 at 11:43