sharepoint online – Connect-PnPOnline with the help of ClientId and a self-signed certificate

Does anyone know how Connect-PnPOnline Using Azure AD APP permissions and a self-signed certificate?


  • Generated a self-signed certificate. Registered password
  • Registered an Azure application. Downloaded a certificate on the application
  • Application permissions granted to the application
  • Agreement of the administrator

enter the description of the image here

Now, I'm trying to connect-PnPOnline using the script below:

    $certificatePassword = 'CERTIFICATE_PASSWORD'
    $secureCertificatePass = ConvertTo-SecureString -String $certificatePassword -AsPlainText -Force

    Connect-PnPOnline `
        -CertificatePath "C:...DeploymentApp.pfx" `
        -Tenant `
        -ClientId fff6667e-1141-4bb5-ba3e-eaaf653975c6 `
        -Url `
        -CertificatePassword $secureCertificatePass `

I receive a useless error:

Connect-PnPOnline: an exception was issued by the target of a
invocation. On line: 5 characters: 1
+ Connect-PnPOnline `
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo: NotSpecified: (:) (Connect-PnPOnline), TargetInvocationException
+ FullyQualifiedErrorId: System.Reflection.TargetInvocationException, SharePointPnP.PowerShell.Commands.Base.ConnectOnline

Using the latest PowerShell PnP module: SharePointPnPPowerShellOnline 3.13.1909.0

Can any one recommend anything, please?


Found problem related with no resolution yet.


You can try to easily reproduce my case:

  • Get these scripts on your local folder.
  • Install Azure CLI on Windows.
  • Right-click Register_AD_App.bat and "Run As Administrator".
  • You will be prompted to enter an administrator account for your Azure AD / Office 365.
  • In the end, the application will be saved, consent being granted to the permissions of the SharePoint API.
  • The o365AppDetails.json file containing an automatically generated certificate password will be created. You can use this password for the script of the -CertificatePassword param of the Connect-PnPOnline commandlet.

enter the description of the image here