I have a ps1 file running in powershell started by a SSIS job which connects to sharepoint and downloads excel files.
Here the first part of the script that cause error:
$SiteURL = "https://mycompany.sharepoint.com/proj"
$UserName="myUsername"
$Password = "myPassword"
$SecurePassword = ConvertTo-SecureString -String $Password -AsPlainText -Force
$Cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $UserName, $SecurePassword
#connect to sharepoint online site using powershell
Connect-PnPOnline -Url $SiteURL -Credentials $Cred
Since last week the job continuously goes into error, this is the message:
Connect-PnPOnline : AADSTS700016: Application with identifier '31359c7f-bd7e-475c-86db-fdb8c937548e' was not found in the directory 'mydirectory'. 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: 59f79c96-52f1-418e-b33a-fbe8e75d3200
Correlation ID: fd203fca-72c1-4ce1-bc4c-92d639b47ccc
Timestamp: 2024-09-16 07:59:07Z
At C:mypathSPDownload.ps1:12 char:1
Connect-PnPOnline -Url $SiteURL -Credentials $Cred
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : NotSpecified: (:) [Connect-PnPOnline], MsalServiceException
FullyQualifiedErrorId : Microsoft.Identity.Client.MsalServiceException,PnP.PowerShell.Commands.Base.ConnectOnline
I tried connecting manually by opening sharepoint and running the command but I get the same error.
I just ran into this issue. I am getting it straightened out, but here is more information on what happened and how to fix it:
“As part of a focus on improving the security posture, the multi-tenant PnP Management Shell EntraID app has been deleted.”
https://github.com/pnp/powershell/discussions/4249
AADSTS700016 is an error code that indicates that the application you are trying to sign in to is not registered in Azure AD.
To fix this issue, you need to register the application in Azure AD.
Here are the steps to register an application in Azure AD:
- Open the Azure portal and sign in as a global administrator or
co-admin. - Select All services at the top of the navigation pane on the left
side to open the Azure AD extension. - Type Azure Active Directory in the filter search box, and then
select Azure Active Directory. - Select App registrations in the Azure AD navigation pane.
- Select New registration to register a new application.
- Enter a name for the application and select the supported account
types. - Select Register to create the application.
I would also suggest looking at this thread’s solution in case it applies to your case.