PowerShell – PnPOnline – resolving error -Connect-PnPOnline : AADSTS700016: Application with identifier ‘31359c7f-bd7e-475c-86db-fdb8c937548e’ was not found in the directory

Connect-PnPOnline - error while connecting to SharePoint site using "username" and "password"
Connect-PnPOnline - error while connecting to SharePoint site using "username" and "password"

Hi All,

Today new issue and solution 🙂 Short article but it important to know.

Background

  • If we are using PnP PowerShell and if we are authenticating using “UserName” and “Password” then authentication will fail now.
  • I was using “Connect-PnPOnline” CMDLET to connect one of the my site.
  • I am using “Get-Credential” CMDLET to get the credentials.
$cred = Get-Credential
Connect-PnPOnline -Credentials $cred

  • As I am submitting the credentials and trying to connect getting the following error.

Error / Issue

Connect-PnPOnline : AADSTS700016: Application with identifier ‘31359c7f-bd7e-475c-86db-fdb8c937548e’ was not found in the directory
‘knowledge Junction’. This can happen if the application has not been installed by the administrator of the tenant or consented to by
any user in the tenant. You may have sent your authentication request to the wrong tenant. Trace ID:
f5f15ce6-8686-4ac5-8449-5734d2c51000 Correlation ID: b845b4f0-3d54-4877-b026-f00adf43e184 Timestamp: 2024-10-27 02:52:28Z
At line:2 char:1

  • Connect-PnPOnline -Credentials $cred
  • ~~~~~~~~
    • CategoryInfo : NotSpecified: (:) [Connect-PnPOnline], MsalServiceException
    • FullyQualifiedErrorId : Microsoft.Identity.Client.MsalServiceException,PnP.PowerShell.Commands.Base.ConnectOnline
Connect-PnPOnline - error while connecting to SharePoint site using "username" and "password"
fig : Connect-PnPOnline – error while connecting to SharePoint site using “username” and “password”
Connect-PnPOnline - error while connecting to SharePoint site using "username" and "password"
fig : Connect-PnPOnline – error while connecting to SharePoint site using “username” and “password”

Why this ERROR / Cause

  • Recent changes to PnP PowerShell are causing authentication failures.
  • The change is made to improve security.
  • From September 9, 2024, now it is not possible to use PnP PowerShell using -Interactive or -Credentials parameters.

Solution

Register-PnPEntraIDAppForInteractiveLogin -ApplicationName "LIFE IS BEAUTIFUL" -SharePointDelegatePermissions "AllSites.FullControl" -Tenant knowledgejunction1.onmicrosoft.com -Interactive
Executing PowerShell CMDLET to create application object (appid / clientid) - Register-PnPEntraIDAppForInteractiveLogin
fig : Executing PowerShell CMDLET to create application object (appid / clientid) – Register-PnPEntraIDAppForInteractiveLogin
  • We can verify our app in Entra ID – Entra ID >> Applications >> Enterprise applications
Register-PnPEntraIDAppForInteractiveLogin
fig : Microsoft Entra ID – New app “LIFE IS BEAUTIFUL” app created
#Variables
$SiteURL = “<Site URL>”
$ClientID = "<Client ID>"
 
# Connect to SharePoint Online site
Connect-PnPOnline -Url $SiteURL -Interactive -ClientId $ClientID
Connect-PnPOnline using newly created client id
fig : Connect-PnPOnline – connected using newly created client id

REFERENCES

Prasham Sabadra

LIFE IS VERY BEAUTIFUL. ENJOY THE WHOLE JOURNEY :) Founder of Microsoft 365 Junction, Speaker, Author, Learner, Developer, Passionate Techie. Certified Professional Workshop Facilitator / Public Speaker. Believe in knowledge sharing. Around 20+ years of total IT experience and 17+ years of experience in SharePoint and Microsoft 365 services Please feel free me to contact for any SharePoint / Microsoft 365 queries. I am also very much interested in behavioral (life changing) sessions like motivational speeches, Success, Goal Setting, About Life, How to live Life etc. My book - Microsoft 365 Power Shell hand book for Administrators and Beginners and 100 Power Shell Interview Questions - https://www.amazon.in/Microsoft-Administrators-Beginners-Interview-Questions/dp/9394901639/ref=tmm_pap_swatch_0?_encoding=UTF8&qid=1679029081&sr=8-11

You may also like...

1 Response

  1. November 19, 2024

    […] PowerShell – PnPOnline – resolving error -Connect-PnPOnline : AADSTS700016: Application with identifier ‘31359c7f-bd7e-475c-86db-fdb8c937548e’ was not found in the directory – https://microsoft365junction.com/2024/10/27/powershell-resolving-error-connect-pnponline-application&#8230; […]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Microsoft 365

Subscribe now to keep reading and get access to the full archive.

Continue reading