Skip to content

[BUG] Connect-PnPOnline ignores the WarningAction and WarningPreference parameters when using the a cached token #5078

@b-a0

Description

@b-a0

Reporting an Issue or Missing Feature

After creating a persisted login token, subsequent calls to Connect-PnPOnline (e.g. to connect to a different context) print a warning:

WARNING: Connecting using token cache. See https://pnp.github.io/powershell/articles/persistedlogin.html for more information.

As it's a warning I thought setting the WarningAction or WarningPreference to SilentlyContinue would suppress this message.

Expected behavior

Expected to see no WARNING after I've set WarningAction or WarningPreference to SilentlyContinue.

Actual behavior

I keep seeing the warning, regardless of my preferred warning action:

Image Image

Steps to reproduce behavior

Please include complete script or code samples in-line or linked from gists

$WarningPreference='SilentlyContinue'
Connect-PnPOnline -Url https://<tenant>.sharepoint.com -PersistLogin
$url="https://<tenant>.sharepoint.com/teams/<identifier>"
Connect-PnPOnline -Url $url

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

3.1.0

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

  • 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