Error Action Preference in PowerShell
This may help to troubleshoot the PowerShell Script errors:
Command: $ErrorActionPreference = "Silently Continue"
Error Message:
Cannot convert value "Silently Continue" to type "System.Management.Automation.ActionPreference". Error: "Unable to match the identifier name Silently Continue to a valid enumerator name. Specify one of the following enumerator names and try again: SilentlyContinue, Stop, Continue, Inquire, Ignore, Suspend"
At line:1 char:1
- $ErrorActionPreference = "Silently Continue"
-
+ CategoryInfo : MetadataError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : RuntimeException
Cause:
Silently Continue should be SilentlyContinue
Notice the white space character between Silently and Continue.
At times this helps solve when we missed tracing the type in large scripts:
$ErrorActionPreference = 0
**
Details:
**
$ErrorActionPreference = 0 #is SilentlyContinue $ErrorActionPreference = 1 #is Stop $ErrorActionPreference = 2 #is Continue $ErrorActionPreference = 3 #is Inquire $ErrorActionPreference = 4 #is Ignore |
This gave a clue. Issue Resolved.
Best Practice: $ErrorActionPreference = 2 is Continue
**