I'm trying to run my Powershell PnP script using ClientId and ClientSecret instead of UseWebLogin. I already created an Azure Application ID using this tutorial (but skipping the certificate part for the moment):


This is my code:

#Install-Module SharePointPnPPowerShellOnline
#Config Variables
$SiteURL = "https://myname.sharepoint.com/"

    Try {
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -ClientId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -ClientSecret "Sdf9Q~9pZErHkefW0Zt77IryFh-6vk_vI6B-Fch2"


 catch {  
     write-host "Error: $($_.Exception.Message)" -foregroundcolor Red

I get this error:

Get-PnPsite : Cannot contact site at the specified URL https://myname.sharepoint.com/. The app principal does not exist. At line:9 char:1

Using the UseWebLogin all is working.

What did I do wrong or miss in creating the Azure Application?

  • Don't you miss the -Tenant argument? For example: -Tenant 'myname.onmicrosoft.com'
    – jleture
    Commented Jun 27 at 5:01
  • No, -Tenant parameter does not exist when using -ClientSecret but it works if I use -Thumbprint, and at this point I wonder if -ClientSecret is usable here.
    – Dylan666
    Commented Jun 27 at 14:18
  • So maybe you're using AppId instead of ClientId... That's why you have the error The app principal does not exist.
    – jleture
    Commented Jun 27 at 18:28


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.