Skip to main content
10 votes
Accepted

How can I count Document library in Sites(SPWeb) Level?

No need for looping , just get the library at a specific site based on the base type equal to DocumentLibrary then get count of collection as the following : using(SPSite site = new SPSite("https://...
Mohamed El-Qassas MVP's user avatar
6 votes

How to get the value of list count in SPWeb level?

SPWeb.Lists.Count.ToString(); is correct way to find number of Lists for any SPWeb. You might be seeing in difference in count you see here and in Site is because SharePoint has couple of hidden list ...
Siddharth Vaghasia's user avatar
6 votes

How can I count Document library in Sites(SPWeb) Level?

You can try this- as bellow using(SPSite oSite = new SPSite("https://server/site")) { using (SPWeb oWeb = oSite.OpenWeb()) { SPListCollection docLibraryColl = oWeb.GetListsOfType(...
Ram's user avatar
  • 2,444
5 votes
Accepted

Cannot get Webs of SPSite object

All permissions required to correct this error: Site Collection administrator on the SPSite (whether given through Central Admin or Site Settings) PowerShell scripting admin: add-spshelladmin domain\...
Karthik Jaganathan's user avatar
4 votes
Accepted

How to get the value of list count in SPWeb level?

This is because of the SPWeb.Lists.Count.ToString(); return the number of all lists and libraries not only lists To can get the accurate number of lists only you should exclude the library and other ...
Mohamed El-Qassas MVP's user avatar
4 votes
Accepted

Should i use "using" inside event receiver

No, you should not use a using as you're not instantiating the object - you're getting a reference to an existing object. Let the event receiver handle the life cycle of its own objects.
Derek Gusoff's user avatar
  • 8,054
3 votes

Get all groups for a specific web site (NOT SITE COLLECTION) using powershell?

I found the solution. This article helped me out. $web = Get-SPWeb $webUrl; $groups = $web.AssociatedGroups;
ameliapond's user avatar
3 votes
Accepted

Why SPWeb.Group provide a method named Add() that always raises exceptions (that we can not use)

The short answer to this question is, Add method is there for Type consistency which makes the life easier for the Developers, both the SharePoint library(dll) developers and general SharePoint ...
AmitWiki's user avatar
  • 1,029
3 votes
Accepted

incorrect documentation about the SPItemEventProperties.OpenWeb() method inside visual studio 2012

The SharePoint terminology is vert confusing. Officially, you have the "site collections", and each site collection contains "site"s (the root site and all its sub-sites are sites). There's no "web"...
Evariste's user avatar
  • 9,731
3 votes

cant find /_layouts/AreaTemplateSettings.aspx

here is a solution for publishSites: Open the publishing site in SharePoint Designer 2013. Click the Site Settings icon on the ribbon. SiteOptions_in_SPD Modify the parameter ...
Imen Turki's user avatar
  • 2,193
3 votes

How to get the value of list count in SPWeb level?

Try following code using (SPSite site = new SPSite("Web Url")) { using (SPWeb web = site.OpenWeb()) { Console.Write(web.Lists.Count); Console.ReadLine(); } }...
Akshay Belure's user avatar
2 votes
Accepted

Determine path to site from a given URL

Try with following JS code <script src="https://code.jquery.com/jquery-1.11.2.min.js"></script> <script> var owebsite; var documentPath = "http://sharepointsite/subsite/Shared%...
Viraj Gorajia's user avatar
2 votes

How can I count Document library in Sites(SPWeb) Level?

Get the document library count using LINQ: SPSite site = new SPSite("siteURL"); SPWeb web = site.OpenWeb(); var totalDocLibrary = (from SPList lst in web.Lists ...
Ronak Patel's user avatar
  • 3,261
2 votes

Why SPWeb.Group provide a method named Add() that always raises exceptions (that we can not use)

Let me first elaborate the difference between SPWeb.Groups and SPWeb.SiteGroups SPWeb.Groups Get a collection that contains all the groups for the subsite. SPWeb.SiteGroups Get a collection that ...
Mohamed El-Qassas MVP's user avatar
2 votes
Accepted

Modifying a list item field using powershell without changing the following values (modifed/modifiedby/Version)

The SystemUpdate() method is indeed what you are looking for. This method will update the item without changing the Modified, Modified By, and Version fields. Your PowerShell script will do exactly ...
Mihail's user avatar
  • 2,079
1 vote
Accepted

Group cannot be found

We can add the method below to solve this issue. static string GetRichTextValue(string value) { if (null == value) { return string.Empty; } StringBuilder sb = new ...
LZ_MSFT's user avatar
  • 6,249
1 vote
Accepted

SP16 - Change Web top navigation with PowerShell

I think you want to make sure global and current navigation are set to use structural navigation. For that, you can use the below PowerShell script: $spWeb = Get-SPWeb -Identity $webURL #setting ...
Gautam Sheth's user avatar
1 vote

SPContext.Current is null while calling SPContext.Current.Web.EnsureUser() method

SPContext.Current can only be used from a Web context. This means it works fine as long as an HttpContext exists. By definition, this is always the case for Web parts, controls and Web pages. ...
Evariste's user avatar
  • 9,731
1 vote

Empty properties? when I call $web.GetFile() method from Powershell

I think your file does not exist, or you are not setting the url parameter correctly. Double check $wpDestinationPageFullUrl. $web.GetFile OverloadDefinitions ------------------- Microsoft....
Tiago Duarte's user avatar
  • 5,497
1 vote

How to check if a subweb exists within a web

This has some issues: Performance: If you have many webs, many objects will be created. Disposing: I'm not sure if these SPWeb objects needs to be disposed or if SharePoint keeps track of them and ...
JanErikGunnar's user avatar
1 vote

Get all groups for a specific web site (NOT SITE COLLECTION) using powershell?

In SharePoint 2010 the Web Object has different properties to get site groups and web groups. $web = Get-SPWeb $webUrl //Gets a collection that contains all the groups in the site collection. $...
Venkat Konjeti's user avatar
1 vote

Open web in privileges mode and use it outside

It's not a good practice at all to open an SPWeb in an elevated context with RunWithElevatedPrivileges, close the elevated context and then continue using he SPWeb. A much more simple approach is to ...
Evariste's user avatar
  • 9,731
1 vote

Space in URL causes fail in get-spweb?

You need to put quotes around parameter $SPWeb = Get-SPWeb "http://mysite/web name 1"
Siddharth Vaghasia's user avatar
1 vote

Space in URL causes fail in get-spweb?

It would be $SPWeb = Get-SPWeb "http://mysite/web name 2"
Eric Alexander's user avatar
1 vote
Accepted

How do I differentiate between getchanges REST API call for SPSite and SPWeb?

If you want to query particular object with REST API, you need to use appropriate object in url. For example consider following REST queries: Get changes for site collection: https://sp....
Sergei Sergeev's user avatar
1 vote

How can I count Document library in Sites(SPWeb) Level?

using(SPSite site = new SPSite("https://sitecollectionurl")) { using (SPWeb web = site.OpenWeb()) { int i = 0; foreach (SPList list in web.Lists) { if (list.BaseType == ...
Gautam Sheth's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible