#create a new certificate New-PnPAzureCertificate ` -CommonName "Demo_SP_Azure_2024" ` -OutPfx c:\code\Demo_SP_Azure_2024.pfx ` -OutCert c:\code\Demo_SP_Azure_2024.cer ` -CertificatePassword (ConvertTo-SecureString -String "Taco@Good" -AsPlainText -Force) ` -ValidYears 1 #save the certificate to the certificate store Import-PfxCertificate ` -Exportable ` -CertStoreLocation Cert:\LocalMachine\My ` -FilePath c:\code\Demo_SP_Azure_2024.pfx ` -Password (ConvertTo-SecureString -String "Taco@Good" -AsPlainText -Force) #create a new App Registration in Azure and select the SharePoint selected.sites permission Register-PnPAzureADApp ` -ApplicationName Demo_SP_Azure_2024 ` -Tenant tacoranch.onmicrosoft.com ` -Store CurrentUser ` -SharePointApplicationPermissions "Sites.Selected" ` -Interactive #connect to the SharePoint tenant and grant the app permissions to the site Connect-PnPOnline -Url "https://tacoranch-admin.sharepoint.com" -Interactive Grant-PnPAzureADAppSitePermission ` -AppId 'a95ddafe-6eca-488a-b26a-dc62a64d9105' ` -DisplayName 'Demo_SP_Azure_2024' ` -Site 'https://tacoranch.sharepoint.com/sites/cert-demo' ` -Permissions Write #connect to the site using the certificate Connect-PnPOnline ` -Tenant "tacoranch.onmicrosoft.com" ` -Url "https://tacoranch.sharepoint.com/sites/cert-demo" ` -ClientId "a95ddafe-6eca-488a-b26a-dc62a64d9105" ` -Thumbprint "5C5891197B54B9535D171D6D9DD7D6D351039C8E" #list the lists in the site Get-PnPList | Select-Object Title