Reading all OneDrives using certificate in Azure app

Copper Contributor

I am connecting to PnPOnline successfully with an azure App with a certificate.

But when I attempt to read all OneDrives, it fails with "Attempted to perform an unauthorized operation."

My azure app registration has SharePoint Sites.Read.All permissions.

I've tried different combinations of parameters - they all return the same message.

Can someone shed some light on what I may be missing?


$tenantUrl = https://<tenant>'

$tenant = '<tenant>'


Connect-PnPOnline -ReturnConnection -Url $targetUrl -ClientId $clientID -CertificatePath '<path to .pfx file'> -CertificatePassword $password  -Tenant $tenant


$OneDrvs = Get-PnPTenantSite -Connection $connection -IncludeOneDriveSites -Template "SPSPERS#10"


This version threw the same error:

$OneDrvs = Get-PnPTenantSite -Connection $connection -IncludeOneDriveSites -Filter {"Url -like ''"}


0 Replies