Wednesday, October 11, 2017

Find SharePoint List Column available via SharePoint Server Side Code

you can use Fields.ContainsField to check if the List Column exists from the custom List, So that, you can avoid error for running Custom Code Webpart.

  LogMessage("RequestID " + Reqitem["RequestID"], EventLogEntryType.Error);

  dr["Requisition No"] = Convert.ToString(Reqitem["RequestID"]);
    LogMessage("Not Available RequestID ", EventLogEntryType.Error);

Thursday, August 3, 2017

Tuesday, June 13, 2017

Using PowerShell to Get SharePoint Content database size

To get the all CONTENT_DB  size in SHAREPOINT server(MB), Using below commands power shell commands.

Get-SPDatabase | Sort-Object disksizerequired -desc | Format-Table Name, @{Label ="Size in MB"; Expression = {$_.disksizerequired/1024/1024}} >c:\Content_DBsize.txt

The above code will export to C drive and you can change drive for your requirement.

Monday, May 8, 2017

Inherit Subsite Master Page from Parent Master Page in Sharepoint Foundation 2013

Do you want to change the master page setting for just one site, then use the script below:

$web = Get-SPWeb siteurl
$web.MasterUrl = "masterpagerelativeurl"

The script would be as follows:

$web = Get-SPWeb http://portal/sites/collaboration
$web.MasterUrl = "/sites/collaboration/_catalogs/masterpage/customSeatle.master"

Refreshing the root site in the browser will show the new master page design, but all sub-sites will still show the old master page design – this is because they are each using a master page stored on their respective site. To change the master page setting for all sites in a site collection, use the following script:

$site = Get-SPSite http://portal/sites/collaboration
$site | Get-SPWeb -limit all | ForEach-Object { $_.MasterUrl = "/sites/collaboration/_catalogs/masterpage/customSeatle.master";$_.Update() }

Note that this will only change existing sites and will not set a custom master page for any new sites created. To update new sites, you will need to either run the script every time a new site is created, or use an alternative approach such as a feature receiver/stapler or Web provisioning event receiver to automatically set the new master page on site creation.

Do you want to revert all team sites in the site collection back to using their own default master page again, then use the following script:

$site = Get-SPSite http://portal/sites/collaboration
$site | Get-SPWeb -limit all | ForEach-Object { $_.MasterUrl = $_.ServerRelativeUrl + "/_catalogs/masterpage/v4.master";$_.Update() }