powershell icon indicating copy to clipboard operation
powershell copied to clipboard

[BUG] Get-PnPTenantSite command does not return any output if the number of sites is greater than 40k

Open rajarshibhargav opened this issue 1 year ago • 6 comments

Reporting an Issue or Missing Feature

Please confirm what it is that your reporting

Get-PnPTenantSite command does not return any output if the number of sites is greater than 40k

Expected behavior

Please describe what output you expect to see from the PnP PowerShell Cmdlets

Get-PnPTenantSite command should return the correct output even if the number of sites is greater than 40k

Actual behavior

Please describe what you see instead. Please provide samples of output or screenshots.

Get-PnPTenantSite command does not return any output if the number of sites is greater than 40k . We waited close to 20 minutes in order to get an output for this command but we did not get any response. We also want to know if there is any fixed interval that we need to wait for a response under Get-PnPTenantSite command while running it for an organisation having greater than 40k Sharepoint Sites.

Steps to reproduce behavior

Please include complete script or code samples in-line or linked from gists

Run Get-PnPTenantSite command for any organisation which has more than 40k Sharepoint sites.

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

(you can retrieve this by executing Get-Module -Name "PnP.PowerShell" -ListAvailable)

PS /app> Get-Module -Name "PnP.PowerShell" -ListAvailable

Directory: /home/spm/.local/share/powershell/Modules

ModuleType Version PreRelease Name PSEdition ExportedCommands


Manifest 2.2.0 PnP.PowerShell Desk {Add-PnPAdaptiveScopeProperty, Add-PnPPropertyBagValue, Add-PnPSiteClassification, Copy-PnPFolder…}

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

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

rajarshibhargav avatar Apr 08 '24 07:04 rajarshibhargav

Did you store the result in a variable like $result = Get-PnPTenantSite or did you call the command like Get-PnPTenantSite ? Note that the latest version is 2.4.0, try updating it.

jackpoz avatar Apr 09 '24 21:04 jackpoz

We dont store the result in a variable like $result = Get-PnPTenantSite. However we redirect the command output to json like | ConvertTo-Json -Compress -Depth

rajarshibhargav avatar Apr 10 '24 07:04 rajarshibhargav

Hi @jackpoz We have updated the version to 2.4.0, however we are still facing the same issue. Request you to kindly look into this issue and help us with a solution / workaround here.

rajarshibhargav avatar Apr 19 '24 05:04 rajarshibhargav

I do remember having no issues in a tenant with 300k site collections but I don't have access to that tenant anymore. Does the command get stuck still as you said you waited 20 minutes ?

jackpoz avatar Apr 19 '24 07:04 jackpoz

Yes @jackpoz . From my testing I was able to get 40k Sites after waiting ~ 2 minutes. For organisation with > 40 k sites, I waited beyond 2 minutes (upto 20 minutes) but the command Get-PnPTenantSite never returned anything.

rajarshibhargav avatar Apr 19 '24 10:04 rajarshibhargav

May i request an update on the bug fix here?

rajarshibhargav avatar May 02 '24 04:05 rajarshibhargav

Hi @jackpoz

We have observed that the command Get-PnPTenantSite returns the output even if the number of sites is greater than 40k. This might be likely because this command just returns the names of sharepoint sites.

However if we run the command as in Get-PnPTenantSite | ConvertTo-Json -Compress -Depth to get the site attributes, we dont get any output if the organisation has more than 40k sites.

Hope this helps us to identify the root cause here.

rajarshibhargav avatar May 22 '24 15:05 rajarshibhargav

Please try this:

$sites = Get-PnPTenantSite
$sites.Count

If that shows the correct count, then it's not a PnP PowerShell issue. I would suggest to export the result to csv using Export-Csv as a different way to save the result.

Interestingly enough, it seems ConvertTo-Json has some max size limit inherited from .NET, see https://stackoverflow.com/questions/16854057/convertfrom-json-max-length as old example.

jackpoz avatar May 22 '24 16:05 jackpoz

Thank you @jackpoz . Export-Csv has solved this issue.

rajarshibhargav avatar May 23 '24 07:05 rajarshibhargav

Cannot thank you enough @jackpoz . That answer was super helpful 🙏 🙏 .

ns-khp avatar May 23 '24 07:05 ns-khp

Thank you too, I learnt something new about ConvertTo-Json 👍

jackpoz avatar May 23 '24 15:05 jackpoz