Indexing Large Files in SharePoint 2010

Like it’s predecessor, SharePoint 2010 also doesn’t index files larger than 16 MB by default. This is because the search service application property ‘MaxDownloadSize’ is set to 16 MB by default. We can change this by running the following PowerShell commands and restarting search service.

$dSize = Get-SPEnterpriseSearchServiceApplication;
$dSize.SetProperty("MaxDownloadSize", 32);

The above commands will increase the max size of files that SharePoint can index to 32 MB from 16 MB (default).

To restart search service, run the following command on the indexing server.

Restart-Service osearch14;


Add Only Permission Level in SharePoint 2010

Have you ever had a requirement from your farm users that they need a custom permission level which allows the users/groups to add or submit documents or InfoPath forms into a library but not view or edit them? If you try to create this permission level using SharePoint GUI (Site Permissions > Permission Levels > Add a Permission Level), you will notice that whenever you check the permission “Add Items”, the permission “View Items” will also be checked. There is no way you can check “Add Items” permission alone. But don’t worry, as always, PowerShell is at your help. You can create an add only permission level using the following PowerShell script.

$spweb=Get-SPWeb -Identity "<site url>";
$spRoleDefinition = New-Object Microsoft.SharePoint.SPRoleDefinition;
$spRoleDefinition.Name = "Submit only";
$spRoleDefinition.Description = "Can submit/add forms/files/items into library or list but cannot view/edit them.";
$spRoleDefinition.BasePermissions = "AddListItems, ViewPages, ViewFormPages, Open";

Paste the above script into a text editor and save it into the server with .ps1 extension. From the PowerShell console, execute the ps1 file. You will have the new permission level created in the site collection at <site url>.

Cannot Delete Site Columns from Document Library or Content Type

Recently I ran into an issue where one of the SharePoint users added an existing site column called “Active” into one of the document libraries and was not able to remove it. This is a strange behavior from SharePoint and is because some “AllowDeletion” field property is set to true by default. Anyway, I was able to delete the filed using the following PowerShell script.

$web = Get-SPWeb https://siteurl/
$list = $web.Lists["Shared Documents"]
$field = $list.Fields["Active"]
$field.AllowDeletion = “true”
$field.Sealed = “false”

In this case, the column was added only to the Document Library; not to the site content type. If these types of columns were added to site content types, you could use the following script.

$web = Get-SPWeb http://siteurl/
$ct = $web.ContentTypes["Document"]
$spFieldLink = New-Object Microsoft.SharePoint.SPFieldLink($web.Fields["Active"])

Thanks to Brendan Well’s blog which saved me a lot of time.

Scheduling SharePoint PowerShell Scripts in Windows Server 2008 R2

In order to schedule a SharePoint PowerShell script to be run on specific time in Windows Server 2008 R2, perform the following procedures.

  1. Save your PowerShell script into some folder location with .ps1 extension.
  2. Create a new task in Windows task scheduler. Specify the user account the PowerShell script to use when running.
  3. In Actions, add  new action of type “Start Program”. In the Program/Script section, provide full path of “PowerShell.exe” file. That is, “C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe”.
  4. In the Add Arguments field, it needs two arguments. One is the path to SharePoint Administration Console file and the other is the path to your PowerShell script file. This can be provided as follows:
    • -PSConsoleFile "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\psconsole.psc1" -Command " & ‘<folder path>\<your script file>.ps1’ "
  5. The “Start in” optional filed has to be provided as the folder location where your script resides if your script uses current folder for getting resources files or saving log files.
  6. Set other necessary options such as Triggers, Conditions etc. and save the task.