Thursday, 16 October 2014

The content type “Document Collection Folder” at “…” is sealed.



 The content type “Document Collection Folder” at “…” is sealed - SharePoint 2013


In an Asset Library When user tries to upload a Video file below error pops up 

but this won't pop up if a user tries to upload image files


Solution to Above issue is We need to Activate "Video and Rich Media"  Feature at SiteCollection Level and he has to delete the existing Asset library and create the new Asset library.



Wednesday, 15 October 2014

Break List Item Permissions PowerShell


Break Permissions Item Level / Custom Permissions at item level


Blow PowerShell script will retain list permission and give unique permissions atitem level.

We had a requirement to break all item level permissions and remove all the Groups and individual permissions at the item level and Add Owners group and Approvers group  to all items and also it should retain the permissions of item created by.

At the  item level it will delete the all inherited Groups from List and Add specific groups to each item name called " Owners" with  "Full Control " and "Approvers" with "Design" Permissions.



 clear

asnp "*sh*"

$web=Get-SPWeb -Identity "http://weshare.sedwdev.local/sites/teste"

Write-Host " Author is " $web.Author.DisplayName

$list=$web.Lists.TryGetList("SourceList")

foreach($item in $list.Items)
{
    if(!$item.HasUniqueRoleAssignments)
 {
        $item.BreakRoleInheritance($false)

 for($i=0 ; $i -lt $item.RoleAssignments.Count;$i++)
    {

   if(!$item["Created By"])
{
     $item.RoleAssignments.remove($i)

    $item.Title + "permissions Removed "
  
  } }

  foreach( $grp in $web.Groups)
  {
    
     if ($grp.Name -match "teste Owners")
     {

     $rolAsgnmt=New-Object Microsoft.SharePoint.SPRoleAssignment($grp);

     $roldef=$web.RoleDefinitions["Full Control"]

     $rolAsgnmt.RoleDefinitionBindings.Add($roldef);

     $item.RoleAssignments.Add($rolAsgnmt);

     " Item title is  "+ $item.Title + "  Group Added is  " + $grp.Name

     $item.Update();
    
     }

    elseif ($grp.Name -match "Approvers")
     {

     $rolAsgnmt1=New-Object Microsoft.SharePoint.SPRoleAssignment($grp);

     $roldef1=$web.RoleDefinitions["Design"]

     $rolAsgnmt1.RoleDefinitionBindings.Add($roldef1);

     $item.RoleAssignments.Add($rolAsgnmt1);

     " Item title is  "+ $item.Title + "  Group Added is  " + $grp.Name

     $item.Update();
     }
     }  
 }
 }

OutPut:





Wednesday, 8 October 2014

Remove Duplicates in Search Results Webpart


Remove duplicates in Search Results Webpart


asnp "*sh*"


$resultsPage = "Pages/default.aspx"

$resultsUrl = "$siteUrl/$resultsPage"

$spweb = Get-SPWeb $siteUrl

$page = $spweb.GetFile($resultsPage)

# Check if the page is checked out to someone if so override the checkout

$bool=$page.CheckedOut

if($bool)
{
$page.UndoCheckOut();
}

# checkout the Page

$page.CheckOut()

# Get the web part manager for the page
$webPartManager = $spweb.GetLimitedWebPartManager($resultsUrl, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)

# And pull the web part we want to work on
$webpart = $webpartmanager.WebParts | ? { $_.Title -eq 'Latest News' }

$dataProvider = ConvertFrom-Json $webpart.DataProviderJSON

$dataProvider.TrimDuplicates = 'True'

$webpart.DataProviderJSON = ConvertTo-Json $dataProvider -Compress

$webpartmanager.SaveChanges($webpart)

$page.CheckIn('Setting the duplicates in LatestNews');

$page.Publish('Duplicates were set in Latest News Webpart');

$spweb.Dispose();


OutPut:


Tuesday, 7 October 2014

Increase Site Quota using PowerShell

PowerShell Script to Increase Storage Individual Quota


Increasing the SiteCollection Storage without Specifying Site Quota that is individual level,

Here we are increasing the site quota to 5 GB, and setting Warning to 4.5 GB



clear

asnp "*sh*"

$site=Get-SPSite -Identity "http://sedwdevrtm:432/sites/ProductsSite"

# Here We are setting Max storage to 5GB and Warning level to 4GB

Set-SPSite -Identity $site -MaxSize 5GB -WarningSize 4.75GB 

# we are seeing what is the maximum storage and warning level set for the site.

$site.Quota.StorageMaximumLevel/1GB


$site.Quota.StorageWarningLevel/1GB  


Output: