Skip to content

[BUG] Disconnect-PnPOnline throws terminating error even with -ErrorAction SilentlyContinue #5171

@JDziurlaj

Description

@JDziurlaj

Reporting an Issue or Missing Feature

Issue: Disconnect-PnPOnline does not respect -ErrorAction SilentlyContinue and still throws a terminating exception under normal use conditions. This is inconsistent with PowerShell error-action semantics and makes script-level error handling unpredictable.


Expected behavior

Calling:

Disconnect-PnPOnline -ErrorAction SilentlyContinue

should not throw a terminating exception and should quietly ignore the disconnect request when no active PnP connection exists.

This matches how other PnP cmdlets and standard PowerShell cmdlets behave when using SilentlyContinue.


Actual behavior

Disconnect-PnPOnline -ErrorAction SilentlyContinue
Disconnect-PnPOnline: No connection to disconnect

Steps to reproduce behavior

try {Disconnect-PnPOnline -ErrorAction SilentlyContinue } catch { Write-Host "Got here" }
Got here

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

3.1.218

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

  • Windows

Metadata

Metadata

Assignees

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