Connect-PnPOnline: unwanted credential caching

UPDATE: May 2021

This problem, as described in my original post below, has been fixed for the Connnect-PnPOnline, when using the UseWebLogin param. Plus, the ClearTokenCache parameter is no longer available…

Connect-PnPOnline -Url "https://[tenant].sharepoint.com" -UseWebLogin; 

The “new” (or orignal) experience when calling the above Cmdlet will look like the following screen shot:

Login screen: That didn’t work … Here are a few ideas…

For more options, see https://pnp.github.io/powershell/cmdlets/Connect-PnPOnline.html#example-9

An alternative is to use the Interactive prameter:

Connect-PnPOnline -Url "https://[tenant].sharepoint.com" -Interactive; 

For more information, see https://pnp.github.io/powershell/cmdlets/Connect-PnPOnline.html#example-10

Original Post

Since creating a new Windows 10 profile (new PC) the Connect-PnPOnline PowerShell CmdLet has been caching my primary credentials while using the UseWebLogin parameter.

Connect-PnPOnline -Url "https://[tenant].sharepoint.com" -UseWebLogin; 

This wouldn’t be a problem if I only worked with on tenant…

After a fair amount of Google searching, mucking around with Internet Explorer and Microsoft Edge settings I found that running the Connect-PnPOnline CmdLet with the following parameters worked:

Connect-PnPOnline -Url "https://[tenant].sharepoint.com" -SPOManagementShell -ClearTokenCache;

Once signed you can revert back to using the UseWebLogin parameter, well until the next time the PowerShell console caches the wrong details… 😉

For more information see: https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/connect-pnponline?view=sharepoint-ps

Categories

Recent Posts

  • How to sort an array using Power Automate
    Learn how to sort an array using Power Automate. In this post I share a Power Platform solution containing two example Cloud Flows demonstrating how an array can be sorted. I also briefly explore performance results of running actions in parallel verses serial with some surprising results.
  • How to Add and Remove Accounts from Multi-Select SharePoint Person and Group Fields
    Learn how to use the SharePoint API and Power Automate to add and remove accounts from multi-select Person and Group fields in SharePoint. Our step-by-step guide includes detailed illustrations and examples, as well as an optional Power Platform solution to help you deploy the solution to your tenant. Improve your SharePoint workflow management today!
  • Navigating Microsoft Power Automate Licensing: Challenges, Considerations, and Compliance
    Navigate the complexities of Microsoft Power Automate licensing with insights on challenges, considerations, and compliance. Learn about potential risks, licensing rules, and best practices for organizations using Power Automate. Get guidance on avoiding license breaches, managing premium connectors, and ensuring compliance with Microsoft licensing requirements. Stay informed and take proactive steps to maintain licensing compliance in Power Automate, regardless of your location. Discover practical strategies to optimize your Power Automate licensing and avoid potential pitfalls.
  • SharePoint REST API: How to find the List or Library “__metadata” “type”
    SharePoint REST API is a powerful tool for updating lists and items in SharePoint, but determining the correct “__metadata” “type” for API calls can be confusing. While it’s typically “SP.Data.ListNameItem” based on the list’s URL, there are cases where it may be “SP.Data.ListNameListItem” in certain Office 365 tenants. In this article, we will explore how to find the correct “__metadata” “type” when updating lists or libraries in SharePoint, and also highlight the alternative approach of using the Microsoft Graph API. By understanding this crucial aspect of SharePoint REST API, readers can ensure successful updates and avoid potential errors.
  • “The Age of #AI has begun” said Bill Gates
    March 2023 has been an extraordinary month with the launch of GPT-4 on March 14th, closely followed by #Microsoft’s launch of Copilot preview on March 16th, and Bill Gates’ article, “The Age of AI has begun,” on March 21st.
%d bloggers like this: