Dec 21 2016 05:22 AM
Dec 21 2016 05:22 AM
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: https://msdn.microsoft.com/EN-US/library/microsoft.online.sharepoint.tenantadministration.siteproper...
I found a PowerShell script that uses the same approach as our console application here: https://gallery.technet.microsoft.com/office/How-to-get-all-the-tenant-2999c21b 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 .
Dec 22 2016 08:09 AM
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?
Dec 22 2016 08:34 AM
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.
Jan 04 2017 04:20 AM
Jan 04 2017 04:20 AM
The Microsoft Support Engineer is trying to confirm with the product group that this was intentional.
Feb 09 2017 03:54 PM
Did you hear back from the MS engineer? I'm experiencing the same issue.
Feb 10 2017 07:42 AM
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 adminContext.Load(spp); adminContext.ExecuteQuery(); foreach (SiteProperties sp in spp) { SiteProperties sprops = tenant.GetSitePropertiesByUrl(sp.Url, true); adminContext.Load(sprops); adminContext.ExecuteQuery(); 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; dtSiteStats.Rows.Add(myRow); } startIndex += spp.Count; } }
Feb 10 2017 10:10 AM
Thank you for confirming and for providing your code. I plan to something similar.
Mar 13 2017 08:46 PM
Mar 13 2017 08:46 PM
The Microsoft support team created this blog post to document this issue: https://blogs.technet.microsoft.com/sharepointdevelopersupport/2017/01/18/how-to-get-webscount-and-o...