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://...
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 ...
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(...
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\...
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 ...
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.
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;
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 ...
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"...
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 ...
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();
}
}...
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%...
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
...
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 ...
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 ...
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 ...
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 ...
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.
...
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....
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 ...
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.
$...
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 ...
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"
1
vote
Space in URL causes fail in get-spweb?
It would be $SPWeb = Get-SPWeb "http://mysite/web name 2"
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....
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 == ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
spweb × 162development × 28
spsite × 24
powershell × 22
dispose × 19
2010 × 18
sharepoint-enterprise × 14
2013 × 10
sharepoint-server × 8
2007 × 8
event-receivers × 7
list × 5
sharepoint-foundation × 5
site-collection × 5
splist × 5
properties × 5
runwithelevatedprivileges × 5
groups × 4
splistitem × 4
url × 4
event-handlers × 4
best-practices × 4
spuser × 4
spcontext × 4
sharepoint-online × 3