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

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


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
-Interactiveor-Credentialsparameters.
Solution
- Update the latest PnP PowerShell version – Ensure you’re using the latest PnP PowerShell version.
- We can verify current version module. Please refer article – Small Tips and Tricks – how to know the version of any installed PowerShell module – Get-InstalledModule – https://knowledge-junction.in/2022/12/12/small-tips-and-tricks-how-to-know-the-version-of-any-installed-powershell-module-get-installedmodule/
- Create your own Entra application and assign it the minimal permissions that would require.
- We could register new application using PnP PowerShell – Register-PnPEntraIDAppForInteractiveLogin
Register-PnPEntraIDAppForInteractiveLogin -ApplicationName "LIFE IS BEAUTIFUL" -SharePointDelegatePermissions "AllSites.FullControl" -Tenant knowledgejunction1.onmicrosoft.com -Interactive

- We can verify our app in Entra ID – Entra ID >> Applications >> Enterprise applications

#Variables
$SiteURL = “<Site URL>”
$ClientID = "<Client ID>"
# Connect to SharePoint Online site
Connect-PnPOnline -Url $SiteURL -Interactive -ClientId $ClientID

REFERENCES
- Small Tips and Tricks – how to know the version of any installed PowerShell module – Get-InstalledModule – https://knowledge-junction.in/2022/12/12/small-tips-and-tricks-how-to-know-the-version-of-any-installed-powershell-module-get-installedmodule/

1 Response
[…] 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… […]