interactive icon indicating copy to clipboard operation
interactive copied to clipboard

PowerShell cells still display error when commands use common parameter `-ErrorAction Ignore`

Open rohancragg opened this issue 1 year ago • 0 comments

PowerShell cells still display error when commands use common parameter -ErrorAction Ignore and the error displayed is unhelpful

Example command:

# there will be an error when there is no process with ID=2 but it should be ignored
$process = Get-Process -Id 2 -ErrorAction Ignore
if ($process) {
    Write-Host "Process is running"
} else {
    Write-Host "Process is not running"
}

Screenshot 2023-12-13 175801

see: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-7.4#-erroraction

Version info:

OS: Windows 11 Version: 1.0.461101+09b2630eed4bf45ad5c843caa3420ad14fbcd596 Library version: 1.0.0-beta.23611.1+09b2630eed4bf45ad5c843caa3420ad14fbcd596 Build date: 2023-12-13T10:30:35.2533907Z

rohancragg avatar Dec 13 '23 16:12 rohancragg