Skip to content

[BUG] Submit-PnPSearchQuery: Attempted to perform an unauthorized operation. When query against People Search SourceId #5014

Open
@LuisFalcon003

Description

@LuisFalcon003

Reporting an Issue or Missing Feature

The following error message is returned when trying to query against People Search -SourceId "B09A7990-05EA-4AF9-81EF-EDFAB16C4E31":
"Attempted to perform an unauthorized operation."

Expected behavior

Get all user profiles from People Search, for re-indexing puropose.

Full query:
$profiles = Submit-PnPSearchQuery -Query '-AccountName:spofrm -AccountName:spoapp -AccountName:app@sharepoint -AccountName:spocrawler -AccountName:spocrwl -PreferredName:"Foreign Principal"' -SourceId "b09a7990-05ea-4af9-81ef-edfab16c4e31" -SelectProperties "aadobjectid", "department", "write" -All -TrimDuplicates:$false -RelevantResults

Actual behavior

An error message returned:
"Attempted to perform an unauthorized operation."

Image

Steps to reproduce behavior

  1. Set a Microsoft Entra ID Application with the following permission:
Image
  1. Connect to SharePoint Online using the Microsoft Entra ID application and certificate:
$clientId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
$spoTenantRootUrl = "https://[tenant].sharepoint.com"
$tenantDomain = "mydomain.com"
$certificatePath = ".pfx local path"
$plainTextPassword = "MyPassword"
$secureCertificatePassword = ConvertTo-SecureString -String $plainTextPassword -AsPlainText -Force
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($certificatePath, $plainTextPassword, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable)

Connect-PnPOnline -Url $spoTenantRootUrl -ClientId $clientId -CertificatePath $certificatePath -CertificatePassword $secureCertificatePassword -Tenant $tenantDomain -ErrorAction Stop
  1. Execute query:
$profiles = Submit-PnPSearchQuery -Query '-AccountName:spofrm -AccountName:spoapp -AccountName:app@sharepoint -AccountName:spocrawler -AccountName:spocrwl -PreferredName:"Foreign Principal"' `
    -SourceId "b09a7990-05ea-4af9-81ef-edfab16c4e31" -SelectProperties "aadobjectid", "department", "write" ` -All -TrimDuplicates:$false -RelevantResults

What is the version of the Cmdlet module you are running?(you can retrieve this by executing Get-Module -Name "PnP.PowerShell" -ListAvailable)

3.1.0

Image

Which operating system/environment are you running PnP PowerShell on?

  • Windows
  • Linux
  • MacOS
  • Azure Cloud Shell
  • Azure Functions
  • Other : please specify

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions