-
Notifications
You must be signed in to change notification settings - Fork 381
Description
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:
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