Saturday, March 24, 2012

MOSS Recycle bin stage 1 and stage2


Share point is a great content management tool, but of course suddenly you may receive notifications like memory space issues, add more disk space etc.
Customers reach out to share point administrators, where is the size consuming, what are the cost details, they want all the reports consumed by each site.

To better manage these things in advance, admins need to understand the stage 1 and stage 2 recycle bin concepts.

Generally, MOSS manages the user deleted things in two ways.

Stage One:
  • User directly deletes the data in the site, it will be moved to recycle bin.
  • Deleted item/data stays in the recycle bin for 30 days. (default setting in central admin)
  • It will consume the space under site quota.
  • User can restore the deleted data/item.

Stage Two:

After 30days (default setting in central admin), this deleted item will no longer be available to the end user, it would be moved to stage 2.
  • Only site collection admin can view and restore this item
  • This will not consume the data under site quota limit.
  • Deleted item will stay in the second stage recycle bin for 30 days .
  • After 30 days, it will be permanently deleted in the content database.
The recycle bin stage 1 and stage 2 setting for a site collection can be changed in the general setting in central administration.

The url ends with: _admin/vsgeneralsettings.aspx
(e.g: http://ca:80/_admin/vsgeneralsettings.aspx)

Select the required web application from drop down and change the settings as shown below figure.


If site collection admins want to manually delete the stage1 or stage 2 recycle bin items , they could navigate to site collection administration -->Site collectino Recycle bin.

There , they could take the necessary actions to delete or restore the items from the stage 1 and stage 2.

Only site collection admins can have this privilege.






Thursday, March 8, 2012

sharepoint 2007 power shell script to delete old versions

Recently I had a requirement from customer to delete old versioned documents in the document library to get the free space.

Since share point saves each version as a new copy with occupying the memory in database server, we should keep the limit on major and minor versions to consume the memory space on the database server.

Its very cumbersome to manually go and delete each version of the document in the document library


Below power shell script allows to delete all the old version copies from document library.

 [System.Reflection.Assembly]::Load(”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)
$siteurl="http://siteurl";
$spsite=new-object Microsoft.Sharepoint.SPSite("$siteurl");
$spweb=$spsite.OpenWeb("$weburl");
$splist=$spweb.GetList("/sites/mydocumentlibray");
foreach($splistitem in $splist.items){
$file=$splistitem.File;
$file.Versions.DeleteAll();
}
$spweb.dispose();
$spsite.Dispose();
write-host ">>>finished at "(get-date) `n;


If you want to keep the limited versions in a document library,
the below power shell script will help you.

 [System.Reflection.Assembly]::Load("Microsoft.Sharepoint,Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)
$siteurl="http://siteurl";
$listname="TempEmailDocument";
$spsite=new-object Microsoft.Sharepoint.SPSite("$siteurl");
$spweb=$spsite.OpenWeb();
$splist=$spweb.Lists["$listname"];
$listitems=$splist.items;
$VersionsToKeep=2;
foreach($item in $listitems)
{
$currentVersion=$item.Versions.Count;
if($currentVersion -gt $VersionsToKeep)
{
for($index=$currentVersion-1; $index -gt $VersionsToKeep-1;$index-- )
{
$file=$item.Versions[$index].ListItem.File;
$file.Versions[$index].Delete();
$splist.Update();
write-host "deleting ...." + $item.Name +$file.Versions[$index].VersionLabel+ "...";
}
}
}
$spweb.Dispose();
$spsite.Dispose();
write-host ">>>finished at "(get-date) `n;

In the above code, the number of limited versions are 2.