Steps to reproduce
Run the following expressions:
" some invalid JSON string" | ConvertFrom-Json - ErrorAction Ignore
" some invalid JSON string" | ConvertFrom-Json - ErrorAction SilentlyContinue
Expected behavior
Both expressions write no error to the console, and return either $null or the empty string.
Actual behavior
The expressions write an error to the console and throw the following exception:
ConvertFrom-Json : Invalid JSON primitive: some invalid JSON string.
At line:1 char:12
+ "some invalid JSON string" | ConvertFrom-Json -ErrorAction Ignore
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [ConvertFrom-Json], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.ConvertFromJsonCommand
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1 .14393.206
PSEdition Desktop
PSCompatibleVersions {1.0 , 2.0 , 3.0 , 4.0 ...}
BuildVersion 10.0 .14393.206
CLRVersion 4.0 .30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1 .0.1 Reactions are currently unavailable
Steps to reproduce
Run the following expressions:
Expected behavior
Both expressions write no error to the console, and return either
$nullor the empty string.Actual behavior
The expressions write an error to the console and throw the following exception:
Environment data