Skip to content

[BUG] Get-PnPCopilotAgent - The attempted operation is prohibited because it exceeds the list view threshold #4798

@robertcaretta

Description

@robertcaretta

Reporting an Issue or Missing Feature

I am looping over every site in the tenant. This cmdlet is throwing this error on many sites.
By my estimation it is at least 20% of the sites.

Get-PnPCopilotAgent:
Line |
10 | $agents = Get-PnPCopilotAgent -Connection $connection
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The attempted operation is prohibited because it exceeds the list view threshold.

I also encountered this error on one site.

Get-PnPCopilotAgent:
Line |
7 | $agents = Get-PnPCopilotAgent -Connection $connection
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Value cannot be null. (Parameter 'source')

Expected behavior

No errors.

Actual behavior

Error #1 - Throws an error related to list view threshold.
Error #2 - Throws an error related to Value cannot be null. (Parameter 'source')
Error #3 - Properties don't line up with output. See comment below.

Steps to reproduce behavior

I fetch all sites and assigned to variable $tenantSites. Then loop over them like this...
(Side note, the code formatting in this WYSIWIG editor doesn't work as expected. )

$tenantSites | ForEach-Object {

$connection = Connect-PnPOnline -Url $_.Url -ClientId $gtc.ClientId -Thumbprint $gtc.Certificate.Thumbprint -Tenant $gtc.Tenant -ReturnConnection
$_.Url

$agents = Get-PnPCopilotAgent -Connection $connection

if ($agents.count -ge 1) {
    foreach($agent in $agents) {
      $agent.Name
      $agent.AgentType
      $agent.FileLocation
    }
}

$connection = $null

}

What is the version of the Cmdlet module you are running?

2.99.169

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