Monday, December 30, 2013

SharePoint 2013 Web Application Creation Stuck at "This shouldn't take long"

Problem:
Create new web application from SharePoint 2013 Central Administration site got stuck at "This shouldn't take long" message for long time.
SharePoint 2013 Web Application Creation Stuck at "This shouldn't take long"
Root cause: Insufficient Server memory!

Solution:
Try closing any open application in the server and free-up server memory. Increase the "Shutdown Time Limit" value of Central Administration's Application Pool in IIS! Here is how:

  • Login to your SharePoint server which hosts Central Administration
  • Open IIS manager >> Expand the server name and click on Application Pools.
  • Locate the SharePoint Central Administration v4 application pool. Right click on it and choose Advanced Settings.
  • In the Process Model section, set the Shutdown Time Limit to a greater value. E.g 900.
  • Restart IIS.
This could also happen when your SharePoint servers running out of disk space, database auto-growth setting isn't enabled or your server antivirus preventing certain processes.

Related post: "Internet Explorer Cannot Display This Page" Error when Creating Web Application in SharePoint 2013

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Sunday, December 29, 2013

SharePoint 2013 Maintenance Window Notifications

In continuation to my earlier post: Site Under Maintenance Page for SharePoint , While the solution serves the purpose perfectly by displaying a typical "Site under maintenance" page during occasions like SharePoint patching, upgrade, etc. wouldn't it be nice to intimate end-users about the planned maintenance window in advance?

Well, SharePoint 2013 brings a new class SPMaintenanceWindow to support planned maintenance windows. Here is how it works: Prior to planned maintenance window schedules, You set the maintenance window on SharePoint content databases to display a notification to end users about the Planned maintenance window.

Once user hit SharePoint sites they'll see a notification banner on SharePoint 2013 sites notification area (On Top).  Here is the PowerShell script to set maintenance window notification in SharePoint 2013:

How to Create SharePoint 2013 maintenance window notifications:
Add-PSSnapin Microsoft.sharepoint.powershell -ErrorAction SilentlyContinue

$WebAppURL = "http://sharepoint.crescent.com"

#Get all content databases of the web application 
$ContentDbs = Get-SPContentDatabase -WebApplication $WebAppURL

#Create maintenance Window Object
$MaintenanceWindow = New-Object Microsoft.SharePoint.Administration.SPMaintenanceWindow
$MaintenanceWindow.MaintenanceEndDate    = "12/31/2013 11:59:00 PM"
$MaintenanceWindow.MaintenanceStartDate  = "12/29/2013 12:00:00 AM"
$MaintenanceWindow.NotificationEndDate   = "12/31/2013 11:59:00 AM"
$MaintenanceWindow.NotificationStartDate = "12/25/2013 08:00:00 AM"
$MaintenanceWindow.MaintenanceType       = "MaintenancePlanned"  #Another Option: MaintenanceWarning
$MaintenanceWindow.Duration              = "03:00:00:00" #in "DD:HH:MM:SS" format
$MaintenanceWindow.MaintenanceLink       = "http://support.crescent.com/faq/SPMaintenanceWindow"

#Add Maintenance window for each content database of the web application
$ContentDbs | ForEach-Object  {
 #Clear any existing maintenance window
 $_.MaintenanceWindows.Clear()
 
 #Add New Maintenance Window
 $_.MaintenanceWindows.add($MaintenanceWindow)
    $_.Update() 
 }

The above script gets all content databases associated with the provided web application and sets the maintenance window for site collections residing on them. Here is the script in action:
Maintenance Windows in SharePoint 2013
You can get all of the SharePoint content databases of all web applications by skipping parameter -WebApplication in Get-SPContentDatabase cmdlet.
$ContentDbs = Get-SPContentDatabase

Once the maintenance window is completed, don't forget to clear it!
Get-SPContentDatabase | foreach-object {
    $_.MaintenanceWindows.Clear()
    $_.Update()
 }

BTW, even though the banner says: Sites will be in Read-only mode, actually the script it self doesn't set sites so. We've to make the site collections read-only explicitly, if needed.

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Sunday, December 22, 2013

Create Clickable Image Maps with SharePoint Designer 2010

Image Maps in HTML defines clickable areas in Images. You can specify a list of areas (or hot spots) that will be used as the links within an image. We can create an image map for any classifications such as frequently accessed items/region/department, etc.

Lets see how to create an Image map using SharePoint designer 2010.
  • Open you SharePoint site in SharePoint Designer, Create a new HTML page.
  • Insert >> Picture >> Choose your image from SharePoint site for Image map.
  • Click on the picture. Now from the ribbon, Click on Format tab, Click on Hotspot Icon and choose the relevant Shape for your clickable region in the image.
    image map sharepoint content editor
  • Select the clickable region by drawing the shape on the image. Once done, you'll get the prompt to enter Link URL. 
    creating image map sharepoint designer 2010
  • Once done with all clickable regions, Go to "Code View" of SharePoint designer and copy the code from <P> tag to <P> tag as in the below image
    create an image map using sharepoint designer
  • Go to your SharePoint page, Edit and Insert a Content Editor Web Part. Insert the HTML code copied from SharePoint designer via "Edit HTML Source" 
    html image map sharepoint designer
  • Save and Publish the changes. 
That's all, We've created image map in SharePoint Designer! You can do it for any image by defining clickable areas.
create image map in sharepoint designer
BTW, SharePoint image maps can be created without SharePoint Designer! There are plenty of tools to create image maps.

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Saturday, December 21, 2013

Get / Set Lookup Field Values in SharePoint List using PowerShell

Here is my PowerShell code snippets to read/write lookup field values in SharePoint lists.

Scenario: Consider you have a parent list called "Parent Projects" and child list "Project Milestones". The "Parent Project Name" field from child list is being looked up from the parent list's "Project Name" field.
update lookup field value powershell
Get lookup field value from SharePoint list using PowerShell:
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

#Variables
$WebURL="http://projects.crescent.com"
$ListName="Project Milestones"
$LookupFieldName="Parent Project"

#Get Web and List objects
$Web = Get-SPWeb $WebURL
$List = $Web.Lists.tryGetList($ListName)

if($List -ne $null)
{
    #Get a Row from list
    $Item = $List.Items[0]
    
    #Get Lookup Field Value
    $Lookup = New-Object Microsoft.SharePoint.SPFieldLookupValue($Item[$LookupFieldName])
    
    #Send the output to screen
    write-host $Lookup.LookupValue
}

Read from Multiple-Value Lookup Field:
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

#Variables
$WebURL="http://projects.crescent.com"
$ListName="Project Milestones"
$LookupFieldName="Parent Project"

#Get Web and List objects
$Web = Get-SPWeb $WebURL
$List = $Web.Lists.tryGetList($ListName)

if($List -ne $null)
{
    #Get a Row from list
    $Item = $List.Items[0]
    
    #Get Lookup Field Value
    $LookupValueCollection = New-Object Microsoft.SharePoint.SPFieldLookupValueCollection($Item[$LookupFieldName].ToString())

    Foreach ($LookupValue in $LookupValueCollection)
    {
        write-host $LookupValue.LookupValue

    } 
} 
update lookup column value powershell
How to update lookup column in SharePoint using PowerShell:
To update a lookup column, you can simple use:
$ListItem[LookupFieldName]="Parent-Item-ID;#LookupValue"
 E.g. Say you have a lookup column called "Parent Project Name" in "Project Metrics" list, referencing "Project Name" field from "Parent Projects" list as in the above image. Now, to set the lookup column, you can use:
$ProjectMetrics["ParentProjectName"]="2;#Cloud Devlopment" 
Where: 2 is the ID of the row in the Parent Projects list where Project name is: Cloud development.

PowerShell to Set lookup field in SharePoint:
Here is how to update lookup field in SharePoint using PowerShell
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

#Variables
$WebURL="http://projects.crescent.com"
$ParentListName="Parent Projects" #Lookup Parent List
$ChildListName="Project Milestones" #List to add new lookup value
$ParentListLookupField="Project Name" 
$ChildListLookupField ="Parent Project"
$ParentListLookupValue="Cloud Development" #Parent Project value

#Get Web and List objects
$Web = Get-SPWeb $WebURL
$ParentList = $Web.Lists.tryGetList($ParentListName) 
$ChildList = $Web.Lists.tryGetList($ChildListName) 

    #Add new item in Child List - Project Milestones
    $NewItem=$ChildList.Items.Add()

    #Set Title field for the new list item
    $NewItem["Title"]="Dec 2014 Milestone"

    #Get Lookup Item from Parent List
    $ParentListLookupItem = $ParentList.Items | where {$_[$ParentListLookupField] -eq $ParentListLookupValue}
        
    #Set Lookup Field Value in Child List
    $NewItem[$ChildListLookupField] = $ParentListLookupItem.ID
    $NewItem.Update()   

#Send the output to screen
write-host "Lookup Field value has been updated!"

Add Multiple Values Lookup column using PowerShell:
How about updating lookup field with "Allow Multiple Values" enabled?
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

#Variables
$WebURL="http://projects.crescent.com"

#Get Web and List objects
$Web = Get-SPWeb $WebURL
$ParentProjects = $Web.Lists.tryGetList("Parent Projects") 
$ProjectMileStones = $Web.Lists.tryGetList("Project Milestones") 

    #Add new item in Child List - Project Milestones
    $NewMilestone=$ProjectMileStones.Items.Add()

    #Set Title field for the new list item
    $NewMilestone["Title"]="Dec 2014 Milestone"

    #Object for MultiValue Lookup Field Values
    $LookupValues = New-Object Microsoft.SharePoint.SPFieldLookupValueCollection

    #Get a Lookup Item from Parent List
    $ParentProjectItem = $ParentProjects.Items | where {$_["Project Name"] -eq "Cloud Development"}
    $LookupValue = New-Object Microsoft.SharePoint.SPFieldLookupValue
    $LookupValue.LookupId = $ParentProjectItem.ID
    $LookupValues.Add($LookupValue) #Add to Collection

    #Get an another Lookup Item from Parent List
    $ParentProjectItem = $ParentProjects.Items | where {$_["Project Name"] -eq "Smart Home"}
    $LookupValue = New-Object Microsoft.SharePoint.SPFieldLookupValue
    $LookupValue.LookupId = $ParentProjectItem.ID
    $LookupValues.Add($LookupValue) #Add to Collection

    #Set multi-value lookup field value
    $NewMilestone["Parent Project"] = $LookupValues

    $NewMilestone.Update()   


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Thursday, December 19, 2013

Enable/Disable Custom Error by editing Web.Config using PowerShell

To reveal actual errors in SharePoint, we used to turn off custom error page by editing web.config file, located in the root of SharePoint virtual directory. sharepoint custom error page web.config
  • Open the web.config in Notepad
  • Search for "CallStack", Change it from "false" to "true"
  • Search for "CustomErrors mode", Change its value from "On" to "Off"
  • Save and Close.
Warning: Web.config file is highly sensitive! even a small typo may result your SharePoint site Crash!!

Typical SharePoint 2007 "Unknown Error"
sharepoint custom error web.config
 and SharePoint 2010's "An unexpected error has occurred"
 sharepoint 2010 web.config customerrors
Alright, Wouldn't it be a good idea to make these changes by PowerShell Scripts? Sure, Here is the PowerShell script to enable or disable SharePoint custom error page and reveal actual error by editing Web.Config file:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

Function ConfigureCustomError()
 {
  Param( [Parameter(Mandatory=$true)] [string]$WebAppURL,  [parameter(Mandatory=$true)] $Option )
 <#
  .Description
  This PowerShell function Enables / Disables SharePoint Custom Error by editing web.config file
 .Example
  ConfigureCustomError "http://sharepoint.crescent.com" "OFF"
  This disables SharePoint's default custom error page and reveals actual error
 .Link
  http://www.sharepointdiary.com
  http://twitter.com/SharePointdiary
 .Inputs
  $WebAppURL - Web Application URL in which the Custom Errors to be set 
  $Option - ON or OFF
 .Outputs
  Sets "CustomErrors mode" and "CallStack" values in web.config file
 #>

 #Get the web application
 $WebApp = Get-SPWebApplication $WebAppURL
 #Get the Web Application Zone
 $Zone = $WebApp.AlternateUrls[0].UrlZone
 # Get the IIS settings for the zone
 $IISSettings = $WebApp.IISSettings[$zone]
 # Get the path from the settings
 $WebConfigPath = $IISSettings.Path.ToString() + "\web.config"

 #Backup web.config file
 $now = [datetime]::now.ToString('dd-MM-yyyy hh-mm-ss')
 $BackupFile =$IISSettings.Path.ToString()+ "\web.config.$now"
 copy-item $WebConfigPath -destination $BackupFile

 #Get the Web.config File
 $XMLDoc = new-object System.Xml.XmlDocument
 $XMLDoc.Load($WebConfigPath)
  switch($option)
  {
  "OFF" { 
    #Apply Change
    $XMLDoc.get_DocumentElement()."sharepoint".safemode.callstack = "True"
    $XMLDoc.get_DocumentElement()."system.web".customErrors.mode = "Off"
    Write-Host "Custom Error Mode has been Disabled, Now you can get the actual errors!"
    }
  "ON" {
    $XMLDoc.get_DocumentElement()."sharepoint".safemode.callstack = "False"
    $XMLDoc.get_DocumentElement()."system.web".customErrors.mode = "ON"
    Write-Host "Custom Error Mode has been Enabled, SharePoint displays default custom error Page!"
    }
  }
 $XMLDoc.Save($WebConfigPath)
 }
 #Call the function to Turn OFF custom errors
 ConfigureCustomError "http://sharepoint.crescent.com" "OFF"


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Wednesday, December 18, 2013

jQuery Rotating Banner (Carousel/Image Slider) for SharePoint

In continuation to my earlier post Rotating Banner for SharePoint using jQuery, one enhancement requested by people is: The ability to dynamically fetch images from SharePoint library, so that new banner images can be easily added, existing banners can be modified with out touching the banner code.

So, I've made changes to fulfill these requirement. Now the new rotating banner code dynamically fetches banner images from a specified library using SharePoint web Services and renders the rotating banner on SharePoint. Also the target URL is now editable from SharePoint UI.

Steps to implement jQuery Rotating Banner for SharePoint
  • Step 1: Download the jQuery-Rotating-Banner.zip! (Go to File >> Download from Google drive) This zip file contains all scripts, style sheets and sample images for the banner. Extract them to your local folder.
  • Step 2: Create a new picture library (or even document library can do!), name it as "banner", Open the library in explorer view and upload all files including "images" folder and its files extracted from the jQuery-Rotating-Banner.zip file.
    jquery sharepoint image rotator
    Important: Make sure all of your SharePoint site users granted at least "Read" access to the banner library!
  • Step 3: Create a new Hyperlink column in your banner library, name it as "Target"
     image slider sharepoint 2013
  • Step 4: Go to "images" folder under your banner library, set the target URL for the banners, So that when users click on the rotating banner images, they'll be redirected to respective pages.
    sharepoint jquery banner rotator
  • Step 5: Edit banner.htm and style.css files: Find and replace the hard coded link: "http://sharepoint.crescent.com" with your SharePoint site's URL where you created "banner" library.
  • Step 6: Add a content editor web part, Edit web part properties, Specify the content link as the "banner.htm" file which is located in the "banner" library.
This zip file also contains a static version (banner images are hard-coded) which can be used in not just SharePoint sites but on any site. Here is the sample of the jQuery rotating banner in SharePoint 2010:
jQuery Rotating Banner for SharePoint 2010

Rotating banner/Image Slider for SharePoint 2013 using jQuery:
jQuery Rotating Banner for SharePoint 2013
Banner.HTM Code:
<!DOCTYPE HTML>
<html>
<head>
  <title>jQuery Rotating Banner coded by http://www.SharePointDiary.com</title>

 <link href="http://sharepoint.crescent.com/banner/style.css" rel="stylesheet" type="text/css">
 <script type="text/javascript" src="http://sharepoint.crescent.com/banner/jquery-1.3.2.min.js"></script>
 <script type="text/javascript" src="http://sharepoint.crescent.com/banner/jquery.cycle.all.js"></script>
 <script type="text/javascript" src="http://sharepoint.crescent.com/banner/jquery.easing.1.3.js"></script>
 <script type="text/javascript" src="http://sharepoint.crescent.com/banner/jquery.backgroundpos.js"></script>
 
<script type="text/javascript">
$(window).bind("load", function() {
 setTimeout(function() {
     $('.slideshow').cycle({ 
    fx:    'scrollHorz', 
    delay: 0,
    speed:  500,
    rev: 0,
    next:  '.nextArrow',
    prev:   '.prevArrow'
});
}, 2000);
});

    $(document).ready(function() {
     var soapEnv =
            "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
                <soapenv:Body> \
                     <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
                        <listName>banner</listName> \
                        <viewFields> \
                            <ViewFields> \
                               <FieldRef Name='Title' /> \
          <FieldRef Name='Target' /> \
                           </ViewFields> \
                        </viewFields> \
   <queryOptions> \
    <QueryOptions> \
     <ViewAttributes Scope='RecursiveAll'/> \
     <Folder>http://sharepoint.crescent.com/banner/images</Folder> \
    </QueryOptions> \
   </queryOptions> \
                    </GetListItems> \
                </soapenv:Body> \
            </soapenv:Envelope>";

        $.ajax({
            url: "http://sharepoint.crescent.com/_vti_bin/lists.asmx",
            type: "POST",
            dataType: "xml",
            data: soapEnv,
            complete: processResult,
            contentType: "text/xml; charset=\"utf-8\""
        });
    });

    function processResult(xData, status) {
        $(xData.responseXML).find("z\\:row").each(function() {
   //Get Images from "Images" Folder          
  var Html=" <a href='" + $(this).attr("ows_Target").split(',')[0] +"'><img src='http://sharepoint.crescent.com/banner/images/" + $(this).attr("ows_FileLeafRef").substring($(this).attr("ows_FileLeafRef").indexOf('#')+1, $(this).attr("ows_FileLeafRef").length ) + "'></a>";

        $("#slideimages").append(Html);

        });
    }

</script>
</head>
<body>
<div id="mainWrap">
    <div class="banner">
     <div class="innerWrap">
            <div class="slideshow" id="slideimages"> 
            </div>
            <div class="prevArrow"></div>
            <div class="nextArrow"></div>
  </div>
 </div>       
</div>
</body>
</html>


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Tuesday, December 17, 2013

Find and Delete Orphaned Alerts in SharePoint

Problem Description: In Short - When users leave your organisation and removed from Active Directory (AD) they become orphans in SharePoint! Also their alerts!!

Why we care about them: To keep SharePoint clean, we've to remove em' from all SharePoint sites. So, I've written a PowerShell script to scan all site collections of the web application, find and remove orphaned users from SharePoint here: Find and Delete Orphaned Users in SharePoint with PowerShell

Well, that solves the problem? kind of, but we have one more orphan to clean-up: SharePoint alerts created for orphaned users! Alright, Not a difficult task, Lets make use of the existing script, modify it little, run it before deleting orphaned users!
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Function to Check if an User exists in AD
function CheckUserExistsInAD()
   {
   Param( [Parameter(Mandatory=$true)] [string]$UserLoginID )  
  #Search the User in AD
  $forest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
  foreach ($Domain in $forest.Domains)
  {
   $context = new-object System.DirectoryServices.ActiveDirectory.DirectoryContext("Domain", $Domain.Name)
         $domain = [System.DirectoryServices.ActiveDirectory.Domain]::GetDomain($context)
   $root = $domain.GetDirectoryEntry()
         $search = [System.DirectoryServices.DirectorySearcher]$root
         $search.Filter = "(&(objectCategory=User)(samAccountName=$UserLoginID))"
         $result = $search.FindOne()
          if ($result -ne $null)
         {
           return $true
         }
  }
  return $false  
 }

 #Get All site collections of all web applications
 $sites = Get-SPWebApplication | Get-SPSite -Limit All
 #Iterate through each site collection
 foreach($site in $sites)
 { 

 Write-Host "Processing Site:"$site.Url -ForegroundColor Magenta
  foreach($Web in $site.AllWebs)
 {
  #Arrays to Hold Orphaned Alerts & Users
   $OrphanedAlerts = @()
  $AlertUsers  = @()
  #Get all Alerts created on the web
  $WebAlerts = $web.Alerts 
  #Get Unique Users from All Alerts 
  $AlertUsers = $web.Alerts | foreach { $_.User } | Select-Object -Unique

  #Check if any user with alerts is :Orphan!
  if($AlertUsers.length -gt 0)
  {
   foreach($AlertUser in $AlertUsers)
    {
     #Write-host "Checking User:"$AlertUser
     #Check if the user is valid - Not Orphan
     $UserName = $AlertUser.UserLogin.split("\")  #Get User Name from : Domain\UserName
     $AccountName = $UserName[1]    #UserName
                     if ((CheckUserExistsInAD $AccountName) -eq $false)
                     {
      $OrphanedAlerts+=$AlertUser.Alerts
      }
    }
   if($OrphanedAlerts.Length -gt 0) 
    { 
     Write-Host "Total No. of Orphaned Alerts Found:" $OrphanedAlerts.Length  -ForegroundColor Red
     #Delete each orphaned alert
     foreach ($OrphAlert in $OrphanedAlerts)
     {
      write-host "`nOrphaned Alert:" $OrphAlert.ID" on "$web.Url "List:" $OrphAlert.ListUrl "User:"$OrphAlert.User
      Write-Host "Deleting Orphaned Alert..."
      #$WebAlerts.Delete($OrphAlert.ID)
     }
    }
   }     
 }
 }

This PowerShell script scans and deletes all alerts created for Orphaned users. Please note, I've commented out the line:
#$WebAlerts.Delete($OrphAlert.ID)
Just run the script to see how many alerts on what lists & libraries, Un-comment the above line by removing the # to actually remove orphaned alerts in SharePoint.

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Sunday, December 15, 2013

How to Delete Site with Its Subsites in SharePoint - Quick Way

Problem:  SharePoint doesn't allow you to delete a site with its sub-sites. In other words You cannot delete SharePoint Subsite which has one or more child subsites. You'll have to individually remove each and every child subsite prior removing parent subsite.

Can't delete subsite in SharePoint 2013:
You'll end up in these errors if you try to delete a site with its subsites.

Sorry, something went wrong

There was a problem deleting Web site "/Subsite". Sites that have subsites or certain apps can't be deleted. Please try again after deleting all subsites and removing the apps.


SharePoint 2007 Error: Error deleting web site "/subsiteurl". You can't delete a site that has subsites.

So, to delete a site with subsites in SharePoint, first we have to delete all child subsites and then delete the parent site. What if you have large number of subsites?

Solution: Use "Content and Structure Manager".
Here is the quick trick to delete a subsite from SharePoint site:
  • Go To: Site Actions >> Site Settings >> Under Site Administration, click on "Content and Structure" link. (In SharePoint 2013, its "Content and Structure Logs")
  • Select the check-box on each subsite you want to delete, and choose "Delete" button from the "Actions" menu.
Please note, Content and structure feature is based on "Publishing Feature". You must enable Publishing feature to get content and structure. Obviously, Its not available in SharePoint Foundation!

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Saturday, December 14, 2013

Blocked File Types in SharePoint 2013

Getting "Error: Sorry, something went wrong. The following file(s) has been blocked by the administrator." in SharePoint 2013? Well, This is due to Blocked File Types configuration in SharePoint 2013!
blocked file types in sharepoint 2013

What is Blocked File Types in SharePoint 2013:
Blocked file types is a security mechanism in SharePoint to restrict files based on its extension. Obviously, You want to protect your environment from potential threats via Malicious scripts and executable. Or as part of your governance policies, You don't want your users to upload MP3 files to SharePoint, isn't it? So, blocked file types restrict specific file types from uploading to SharePoint. Users cannot upload these blocked file types to SharePoint list (as a attachment!) or a library.

Please note, SharePoint checks for blocked files ONLY based on file's extension but not actual file type. In other words, You can rename a blocked file (say: EXE file to Doc) to something else to allow SharePoint to upload the file.
Tips: In short, Blocked File types defines File types that are not allowed in SharePoint!

How to Manage Blocked File Types in SharePoint 2013:
Blocked files management is done from SharePoint 2013 Central Administration site. To manage blocked files, Navigate to Central Administration >> Security >> Define Blocked File Types.
unblocking blocked file types in sharepoint
Blocked files list is configured per web application basis. You can get the list via "Manage Web Applications" page as well.
sharepoint blocked file types powershell
Default blocked File Types:
By default, There are 105 blocked file types in SharePoint 2013. To allow or restrict file types, you can edit this list. Just enter one Extension per line.
  • To restrict a file type, simply add that file type extension to this list
  • To remove restriction on a particular file type, Locate and remove that extension from this list.
manage blocked file types sharepoint
Here is the List of default blocked files in SharePoint 2013:
sade
adp
asa
ashx
asmx
asp
bas
bat
cdx
cer
chm
class
cmd
cnt
com
config
cpl
crt
csh
der
dll
exe
fxp
gadget
grp
hlp
hpj
hta
htr
htw
ida
idc
idq
ins
isp
its
jse
json
ksh
lnk
mad
maf
mag
mam
maq
mar
mas
mat
mau
mav
maw
mcf
mda
mdb
mde
mdt
mdw
mdz
msc
msh
msh1
msh1xml
msh2
msh2xml
mshxml
msi
ms-one-stub
msp
mst
ops
pcd
pif
pl
prf
prg
printer
ps1
ps1xml
ps2
ps2xml
psc1
psc2
pst
reg
rem
scf
scr
sct
shb
shs
shtm
shtml
soap
stm
svc
url
vb
vbe
vbs
vsix
ws
wsc
wsf
wsh
xamlx

Add/Remove SharePoint blocked file types with PowerShell:
Here is an example in PowerShell script to get/add/remove blocked file types in SharePoint 2013.
Write-host "Enter the Web Application URL:"
$WebAppURL= Read-Host
$WebApplication = Get-SPWebApplication $webAppURL
$Extensions = $WebApplication.BlockedFileExtensions
    
write-host "Blocked File Types:"
$Extensions | ForEach-Object {Write-Host $_}
 
#To Add a Blocked File type
$Extensions.Add("dlg")
$WebApplication.Update()
write-host "DLG File type has been Blocked"
 
#To Remove a Blocked File type
$Extensions.Remove("dlg")
$WebApplication.Update()
write-host "Blocked File type DLG has been Removed"

How about Files which are already uploaded?
Blocked file type settings are applicable not only to new files which you are going to upload but also to existing files. So, if a blocked file type is already uploaded, you can't edit or view the file. Only delete operation is permitted.

How to restrict a specific file type in SharePoint document library?
What if you want to restrict the document library to allow only PDF files? Well, You have to develop a Event Receiver which fires and checks during "ItemAdding" event. Here is my post: Restrict File Types in SharePoint Document Library Upload using Event Receiver

Here is my another article that includes managing blocked files using PowerShell:  Manage Blocked File Types in SharePoint 2010 .Technet Reference: Manage blocked file types in SharePoint 2013

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Friday, December 13, 2013

How to Add Promoted Search Results using Query Rules in SharePoint 2013

We can promote search results based on specific search phrase entered by end-users in SharePoint 2013. The promoted results will appear on the top of the search results. As best bets/visual best bets are replaced with "Query Rules" in SharePoint 2013, this is a powerful way to promote search results within SharePoint 2013 to brought forward specific results to the users.

Scenario: Say, We've a dedicated site for HR Policies with all Human Resources related content and want to bring this site on top of Search results when user types search query as "HR Policies" or "HR Policy".

How to Add Promoted Search Results in SharePoint 2013 (AKA - Best Bets):
Assuming Search Service Application is configured up and running, Navigate to SharePoint 2013 Central Administration Site:
  1. Central Administration >> Application Management >> Manage Service Applications
  2. Click on the "Search Service Application" link, Which takes you to Search Administration page.
  3. Click on "Query Rules" link from left navigation.
  4. SharePoint 2013 Query Rules section seems bit confusing at the first look.
  5. Select a Result Source as "Local SharePoint Results" and Click on "New Query Rule" link.
  6. Give a Rule Name. Say, "HR Policies". Under Query conditions select "Query Matches Keyword Exactly" and enter Phrases as "HR Policies; HR Policy". Under "Actions" section, click on "Add Promoted Results" Link.
  7. Provide promoted result specifications, such as Result Title, URL, Description. Click on Save" button once done. Promoted results also can point to any document, list/librariy item as well.How to Add Promoted Search Results in SharePoint 2013
  8. Optionally, You can enable Publishing based on dates (When should the rule be active?)
  9. Click the "Save" button in the promoted results page and in the Query Rules Page.
Lets see the result: See the Promoted Results in action. See that the "HR Policies" appears on Top!
How to Add Promoted Search Results using Query Rules in SharePoint 2013
Tips: Promoted results can be set as Site/Site collection level too!


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Thursday, December 12, 2013

Create SSRS Report from SharePoint 2013 List using Report Builder 3.0

Reporting Service integrated with SharePoint provides a rich reporting platform. Lets see how we can create SQL Server reporting services report from SharePoint list data:

Create a Library for Reports and add Report Content Type
To start with, Lets create a Document Library,  Add Report Builder Report content type to create a new report.
  1. Go to Library Setting >> Advance Settings >> Select Yes for “Allow management of content types” and click on Yes.
  2. This Navigates to library settings again. Scroll down and Click on “Add from existing site content types” under “Content Types”
  3. Add “Report Builder Report” content type, and click on “OK”.
Create Report using Report Builder Tool
Go to Files Tab >> Click on drop down on "New Document" Ribbon button >> Choose "Report Builder Report"
sharepoint reporting services
This launches “Report Builder Client 3.0” installation for the first time. Wait for the ClickOnce installation to complete. 
sharepoint reporting services configuration
Make sure your SharePoint site is in trusted sites list in IE, otherwise, it won’t launch client application installation when you click on "Report Builder Report" for the first time!
In the Report Builder, Click on "New Report", choose the Table or Matrix Wizard.
sharepoint reporting services tutorial
Choose "Create a Dataset" option and click on "Next" button
sharepoint reporting services integration
Click on New to create new data source for the report.
sharepoint list reporting services data source
Give a Name to Data source and choose connection type as "Microsoft SharePoint List" and enter the connection string as the URL of your SharePoint site. Click on Credentials Tab
sharepoint reporting services list
Specify the relevant credential settings.
Verify the connection properties by click on "Test Connection" button
Choose the SharePoint lists you want to present as a Report.
Pick the Fields to display.
sharepoint reporting services examples
Set Grouping, Sub-total, Grand Total options
Select the style for your report
 sharepoint 2010 reporting services list
 And finally, we will save our report in the document library we have created in the early step.
That's all. Add Reporting Services Web part to desired locations and point to the report we've created. Here is the SharePoint reporting services from list:
sharepoint reporting services list
Now these reports can be export to Excel, PDF, Word, etc. BTW, Its also possible to build the same report using Visual Studio. Refer: How to Create and Deploy SSRS 2012 Reports to SharePoint 2013

Here is an another related article: SQL Server 2012 Reporting Services and SharePoint 2013 integration configuration

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Wednesday, December 11, 2013

How to Create and Deploy SSRS 2012 Reports to SharePoint 2013

Reporting Services integrated with SharePoint 2013 gives you Rich enterprise reporting features. We've our SQL Server 2012 Reporting services integrated with SharePoint 2013 already. So now we can create reports for SharePoint 2013 using both SQL Server Report Builder 3.0 and using Visual Studio.

Lets create a SQL Server Reporting Services Report using Visual studio and publish to SharePoint 2013 site:
  1. Open Visual Studio 2010 Shell which comes with SQL Server 2012 (formerly “BIDS”), Choose New Project >> "Report Server Project Wizard" type, Give it a name. create SSRS report for SharePoint 2013
  2. This opens Report Project Wizard. Click Next
  3. We've to create a Data source for our report. Choose "New data source", Give it a name and choose Type. In my case, data is in SQL Server. Click on "Edit" button to specify SQL Server database
  4. From the connection Properties dialog box, Specify the Server Name and Database in which our required data live
  5. Now, We get the connection string for our data source. Click on Next
  6. Click on "Add Table" icon from Query Designer, Choose the Tables query, Click on "Add"
  7. Pick the columns to use in the Report. Click on OK.
  8. Now we got the query to use in our reports. Click on Next.
  9. Move fields to relevant sections, such as on Page, Group, and on Report Details section.
  10. Choose the deployment location. In our case its our SharePoint site. Enter Report server as our SharePoint site URL and Deployment Folder as any existing document library URL in our SharePoint site.
  11. Finally, Give a Name to the report. Click on Finish.
  12. One last but not least step is: Go to Project Properties >> Set the Target Locations. Say we've a document library called "Reports" in our SharePoint site. Specify the document library’s full path here. (Set all attributes!)Deploy SSRS to SharePoint
Build and deploy the project, and we are done!

Report Output:
Here is the report we've deployed to SharePoint.
SQL Server Reporting Services 2012 Report Published to SharePoint 2013
We can also use "SQL Server Reporting Services Web Part" to display the report on any location.
SSRS 2012 integrated with SharePoint 2013



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


You might also like:

Related Posts Plugin for WordPress, Blogger...