Skip to content

[BUG] -ErrorAction "Ignore" is no longer respected when commandlets get an error #2558

@ekdegerman

Description

@ekdegerman

Reporting an Issue or Missing Feature

Starting in version 1.12, commandlets no longer respect ErrorAction being set to Ignore, which is something we use extensively when an error is to be expected (e.g. looking to see if something exists) and we don't want it added to the $error variable. The commandlets now throw an error instead. Ignore will need the same exception as SilentlyContinue recently got when #2347 was fixed.

Expected behavior

No terminating error should be thrown from a commandlet when ErrorAction is set to Ignore

Actual behavior

An exception is thrown when using Ignore. SilentlyContinue on the other hand behaves the way we would expect Ignore to behave:
image

Steps to reproduce behavior

Here's a simple example, where the site URL and list name could be replaced with any site and list:
Connect-PnPOnline <enter site url> -Interactive $pnpConnection = Get-PnPConnection $list = Get-PnPList <enter list name> $name = "NonExistingField" $action = "Ignore" if(Get-PnPField -List $list -Identity $name -ErrorAction $action -Connection $pnpConnection) { Write-Host "The field $name already exists" -ForegroundColor Green }else{ Write-host "No error was thrown with $action!" -ForegroundColor Green }

What is the version of the Cmdlet module you are running?

1.12. 0 It worked fine on 1.11.0.

Which operating system/environment are you running PnP PowerShell on?

  • [x ] Windows
  • Linux
  • MacOS
  • Azure Cloud Shell
  • Azure Functions
  • Other : please specify

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions