First published on TECHNET on Jan 18, 2017
This post is a contribution from Mustaq Patel, an engineer with the SharePoint Developer Support team
Prior to CSOM ver 16.1.4727.1000, we can get count of all sites in tenant in SharePoint Online Tenant using SiteProperties.WebsCount. You can find Powershell sample at below link
With CSOM ver 16.1.4727.1000 and SPO Service dated 12/20/2016 onwards, SiteProperties.WebsCount alone as in above Powershell will not return correct value. You will see WebsCount is returned as zero. In addition, other properties returned are either zero or not up to date. You can read more on the issue in below forum.
SharePoint Online Product Group changed the implementation of how these Tenant level API works due to performance reasons. Now if we want to retrieve WebsCount and other properties of a site collection, an additional call to Tenant.GetSitePropertiesByUrl is needed and the Property collection acquired from that call needs to be used to get WebsCount and other properties. Below is the working sample.
Assemblies to Reference
The above two assemblies can be found at C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI
This assembly can be found at C:\Program Files\SharePoint Client Components\16.0\Assemblies)
Below is the code to get the webs count property.
You can also read the above resolution on below blog
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.