SiteProperties.WebsCount property is returning zero (CSOM)

Not applicable

We have a console application (C#) that runs nightly to gather stats about our SharePoint Online environment. It has been logging the number of subsites we have using the SiteProperties.WebsCount property since 9/7/2015. Starting on 12/20/2016, that number has come back as zero instead of the actual value (which is 7,400+). We haven't changed this code since late November and all of the other stat values we gather are valid.


The property is documented here:


I found a PowerShell script that uses the same approach as our console application here: I've attached a PowerShell version of this script that pulls the specific property I'm referring to, .WebsCount.


I've tried a couple of versions of CSOM: Microsoft.SharePointOnline.CSOM.16.1.4727.1200 and Microsoft.SharePointOnline.CSOM.16.1.5903.1200 .

7 Replies

Hi @Deleted,


I've tried the same with Microsoft.SharePointOnline.CSOM.16.1.5903.1200 and it seems to be working without any problem so I don't think that this is related to the version of your CSOM version.


Could this be related to permissions? or an account being locked out?




Hi @Pieter Veenstra - I'm pretty sure it's not related to CSOM.  I'm getting the same results with a few versions of CSOM.


The Microsoft Support Engineer I'm working with has been able to reproduce the issue.  He suggested using the "GetSitePropertiesByUrl" method.  However, I did some testing and the data returned from the "GetSiteProperties" method does not match the data returned from the "GetSitePropertiesByUrl" method for the same site collection.  (TimeZoneID, WebsCount, StorageUsage, LastContentModifiedDate)


He's working to get confirmation from the product group that this is expected behavior or not.  I don't see how this can be anything other than a bug.

The Microsoft Support Engineer is trying to confirm with the product group that this was intentional.

Did you hear back from the MS engineer? I'm experiencing the same issue.

Yes, I did.  The product group confirmed that this is working as expected (I asked them to please update the documentation).


Several of these properties aren't populating (like they did in the past) because of the excessive work it takes to do so.  Instead of getting the details in one call, you have to loop through all of the site collections and get the details for each one.


Here's the code that we implemented (C# / CSOM): [we use a DataTable to store the info]


            using (ClientContext adminContext = new ClientContext(AdminSC))
                int startIndex = 0;
                adminContext.Credentials = new SharePointOnlineCredentials(SCAUserName, SCAPassword);

                var tenant = new Tenant(adminContext);
                SPOSitePropertiesEnumerable spp = null;

                while (spp == null || spp.Count > 0)
                    spp = tenant.GetSiteProperties(startIndex, true); //even though details is set to true it won't work

                    foreach (SiteProperties sp in spp)

                        SiteProperties sprops = tenant.GetSitePropertiesByUrl(sp.Url, true);


                        DataRow myRow = dtSiteStats.NewRow();
                        myRow["SiteCollectionURL"] = sprops.Url;
                        myRow["WebsCount"] = sprops.WebsCount;
                        myRow["StorageUsage"] = sprops.StorageUsage;
                        myRow["TimeZoneId"] = sprops.TimeZoneId;
                        myRow["LastContentModifiedDate"] = sprops.LastContentModifiedDate;

                        //THESE NO LONGER WORK
                        //myRow["SiteCollectionURL"] = sp.Url;
                        //myRow["WebsCount"] = sp.WebsCount;
                        //myRow["StorageUsage"] = sp.StorageUsage;
                        //myRow["TimeZoneId"] = sp.TimeZoneId;
                        //myRow["LastContentModifiedDate"] = sp.LastContentModifiedDate;


                    startIndex += spp.Count;


Thank you for confirming and for providing your code. I plan to something similar.