0
我試圖在SharePoint服務器上獲取網站集列表的完整輸出,以便通過它們進行枚舉並收集數據。我發現下面的代碼:是否有可能獲取SharePoint服務器的網站集列表?
foreach (SPWebApplication wa in SPWebService.ContentService.WebApplications)
{
foreach (SPSite sc in wa.Sites)
{
try
{
Console.WriteLine("Do something with site at: {0}", sc.Url);
}
catch (Exception e)
{
Console.WriteLine("Exception occured: {0}\r\n{1}", e.Message, e.StackTrace);
}
finally
{
sc.Dispose();
}
}
}
但不幸的是,這將引發以下錯誤:
System.NullReferenceException: Object reference not set to an instance of an object.
是否有這樣做的一種可能的方式或將我必須提供服務器名稱(即使我」中號直接在SharePoint服務器上運行此代碼)
StackTrace是什麼錯誤?並嘗試[this](http://blog.rafelo.com/2008/07/22/iterating-through-sharepoint-web-applications-site-collections-and-sites-webs/) – Damith
常見原因 - 未運行在SharePoint服務器上,不以管理員身份運行(提升)。 –
Stacktrace包含在上面,它也在SharePoint Server上運行並以管理員身份運行。 – Codingo