Monday, August 27, 2012

Clear your recycle-bin with PowerShell.

My team recently developed this script....it'll clear your recycle-bin with PowerShell & no need to do it 200 at a time.

$url = "http://your site name/sites/site";
$siteCollection = New-Object Microsoft.SharePoint.SPSite($url);
$siteCollection.RecycleBin.Count;
$siteCollection.RecycleBin.DeleteAll();
$siteCollection.Dispose();

Cheers!!!

Saturday, August 25, 2012

Moving content database & creating web application on new server farm

Scenario:

There are situations where you want to propagate one SharePoint web application to some other farm/machine.  

The fastest way is to take content database backup and restore it in your destination farm.

Pre-requisites:
So you have your content database backup.

Creating content database from backup:
Go to your database server and do following:
  • Create a blank database that will be used as content database
  • Restore a database using content database back up from source farm.
Creating a web application:
  • Go to sharepoint central administration and create a new web application
  • While creating a new web application, use existing content database in database section
Validating the web application:

  • Go to sharepoint central administration, click on application management. In "Databases" section you will find "Manage content databases"
  • Choose your application and it will show database status and number of site collections. If you are not sure how many site collections are there in backup, anything greater than 0 is good news.
Configure web application to work properly:

  • Go to sharepoint central administration
  • Click on "Application Management"
  • In "Site Collections" section click on "Change site collection administrators"
  • choose your web application set proper data in site admins.
Cheers!!!

Monday, June 25, 2012

word document to pdf conversion in SharePoint 2010

Points to remember:
1. Use this as a Farm Solution, Sandbox may have some API's restrictions.
2. Assume you want to add a document to a document library and that document should be converted to a PDF document.



Here is the code, for example you can add this code on ITEMADDED() event receiver of the document library.

using System.
using Microsoft.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Utilities
using Microsoft.office.word.server.Conversions;


//verify is document added is a word document
if(properties.Listitem.Name.Contains(".docx") || properties.Listitem.Name.Contains(".doc"))
{
ConversionJosSettings jobSettings;
ConversionJob pdfConversion;
string wordfile;
string pdffile;
//Initiate the conversion settings
jobSettings = new ConversionJosSettings();
jobsettings.Outputformat = saveFormat.PDF;
Create the conversion job using the settings
pdfConversion  = new ConversionJob("Work Automation Services", jobSettings);
//Set the credentials to use when running the conversion job.
pdfConversion.UserToken = properties.web.CurrentUser.UserToken;
//Set the file names
wordfile = properties.WebUrl+ "/" + properties.ListItem.Url;
if(properties.ListItem.Name.Contains(".docx")
{
pdffile =  wordfile.replace(".docx", ".pdf");
}
else
{
pdffile =  wordfile.replace(".doc", ".pdf");
}
//Add the file conversion to conversion job
pdfConversion.AddFile(wordFile, pdfFile);
//Add the conversion job to the word automation services, conversion job queue.
// Conversion job will not take place immediately ( approx15 min process)
pdfConversion.Start();
}



Cheers!!!
Suneet

Friday, April 27, 2012

PowerShell: Total number of documents in SharePoint Site and Sub-Site

Let's say you want to know total number of document's in your SharePoint app including sub-site. Output is an excel file. Change the column in the script if you need additional columns here.



function Get-DocInventory($siteUrl, $outFileNameWithPath) {


[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$rootSite = New-Object Microsoft.SharePoint.SPSite($siteUrl)

$spWebApp = $rootSite.WebApplication

foreach ($site in $spWebApp.Sites) {

foreach ($web in $site.AllWebs) {

foreach ($list in $web.Lists) {

if ($list.BaseType -ne "DocumentLibrary") {

continue}

if ($list.Hidden) {

continue}

foreach ($item in $list.Items) {

$data = @{

"Web Address" = $web.Url

"Doc Lib Name" = $list.Title

"File URL" = $item.Url

"File name" = $item.File.name

"Title" = $item.Title

"Created" = $item["Created"]

"Created By" = $item["Created By"]}

New-Object PSObject -Property $data}}

$web.Dispose();}

$site.Dispose()}

Write-Host "File written to " $outFileNameWithPath}


function Get-Docs()

{

$siteUrl = Read-Host "Enter Site URL"

$outFilePath = Read-Host "Enter output file path (without file name)"

$outFileNameWithPath = $outFilePath.ToString() + "\uploadedDocs.csv"

Get-DocInventory $siteUrl $outFileNameWithPath
Export-Csv -NoTypeInformation -Path $outFileNameWithPath
}

#Set-ExecutionPolicy RemoteSigned
Get-Docs
 
 

Wednesday, April 11, 2012

SharePoint Migration: Migrating a page having DataViewWebPart from SharePoint 2007 to SharePoint 2010

Migrating a page having Data View Web Part from one server to a different server


I got this issue while moving the lists with MetaLogix Migration Manager. It’s a very common issue I have seen people struggling with. Time to fix these issues increases if count of DVWP increases.

By default, SharePointDesigner binds the control to the list instance using the list instance GUID. To resolve this we need to replace the GUIDs by the list name.

The steps to do this are:

1) On the attributes of the DataFormWebPart element replace the attribute ListName="{GUID}" by ListName="LIST_NAME" where LIST_NAME is the name of the list that you are binding to.

2) Go through all of the DataFormParameter elements and replace: WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{GUID}"

With:

WebPartPages:DataFormParameter Name="ListName" ParameterKey="ListName" PropertyName="ParameterValues" DefaultValue="LIST_NAME"


3) Go to the ParameterBindings element and replace

ParameterBinding Name="ListID" Location="None" DefaultValue="{GUID}"


With:

ParameterBinding Name="ListName" Location="None" DefaultValue="LIST_NAME"


This should give you a GUID free DVWP that can be placed on a page layout used by multiple sites on your site collection (as long as the name of the list is the same on all sites).

Cheers!!!

Tuesday, April 10, 2012

Knowledge Base: Let's understand SharePoint 2010 14 hive

Microsoft has replaced the "12 hive" structure that we had in SharePoint 2007 with "14 Hive" structure in 2010.




Some of the folders in 14 hive are :



Program Files\Common files\Microsoft Shared\Web Server Extensions\14 -

This directory is the installation directory for core SharePoint Server files.



Program Files\Common files\Microsoft Shared\Web Server Extensions\14\ADMISAPI -

This directory contains the soap services for Central Administration. If this directory is altered, remote site creation and other methods exposed in the service will not function correctly.



Program Files\Common files\Microsoft Shared\Web Server Extensions\14\CONFIG -

This directory contains files used to extend IIS Web sites with SharePoint Server. If this directory or its contents are altered, Web application provisioning will not function correctly.



Program Files\Common files\Microsoft Shared\Web Server Extensions\14\LOGS -

This directory contains setup and run-time tracing logs.



Other newly added folders are :



Program Files\Common files\Microsoft Shared\Web Server Extensions\Policy -





Program Files\Common files\Microsoft Shared\Web Server Extensions\UserCode -

This directory contains files used to support your sandboxed solutions.



Program Files\Common files\Microsoft Shared\Web Server Extensions\WebClients -

This directory contains files related to the new Client Object Model.



Program Files\Common files\Microsoft Shared\Web Server Extensions\WebServices -

This directory contains new wcf or .svc related files.



Note : You should rewrite and recompile any code that refers to files and resources in "12" Hive structure.For example, if you have redeployed all of your files into the "14" folder and emptied your "12" folder, any references to files under the "12" folder will not work.

Cheers!!!



Wednesday, January 25, 2012

Tired of viewing Correlation ID's searching in Log file under 14 hive

In this topic, i would like to cover how you can find out the error details in SharePoint without going into 14 hive and that big log file. There you are not sure what went wrong and you are not much intrested to find what was the issue.

Though, there are couple of 3rd party tools or freewares are available and you can very well use them but this small script will help you to identify the details with the help of the correlation id.

get-splogevent ?{$_.Correlation -eq ""} select Area, Category, Level, EventID, Message
Format-List

Change the GUID with the correlation ID you have got and that's it.

Cheers!!!
Suneet



Saturday, January 21, 2012

The possible ways: File Share Migration in SharePoint 2010


The possible ways: Migrate file shares to SharePoint 2010

Now your client wants you to suggest something for the 50 GB contents which is lying on the file system. Users are fine with that and they don’t want SharePoint or your client will be more then happy to see these 50 GB contents in SharePoint and enforce users to follow WCM standards by leveraging SharePoint.

Option 1:  You can simply set up SharePoint and let users slowly migrate to it while supporting file shares at the same time. 

Option 2: By creating sites and using the Page Viewer Web Part, the team members can both access the SharePoint site for collaboration and access the read-only file shares. The good thing about this approach is, it feels like you are in SharePoint and using it’s security model. Though it’s correct and another good thing is, if you have imposed any security on your file system contents, it will follow that. J

Option3: Get a third-party tool like Quest Software's File Migrator for SharePoint, AvePoint's DocAve File System Migrator for SharePoint, and Metalogix's FileShare Migration Manager for SharePoint.

You can then decide how you want to proceed.  If your client is good to spend few thousand dollars buy a tool and do it or force users to adopt new platform or let them be there on file system and feel them like they are in SharePoint.

Cheers!!!


Suneet

Did you ever tried - PerformancePoint Services in SharePoint 2010


PerformancePoint Services in SharePoint 2010

The Business Intelligence Center is a prebuilt site collection and site template that you can use to get started with your integration of business intelligence (BI) solutions and SharePoint 2010. Although you can build solutions into other sites or site collections, the Business Intelligence Center provides a foundation of features and SharePoint Components that enables you to quickly create a central location for the presentation of BI information.

What you should know:

PerformancePoint Services allows you to build rich dashboards that pull from a variety of different data sources (such as SharePoint lists, relational data stores, OLAP cubes, and Excel Services). Dashboards might include scorecards, reports, and KPIs (key performance indicators) that provide a summarized view of your business analytics. New PerformancePoint Services features include enhanced scorecards, reports with built-in drill-down features so you can access information quickly, and calculated metrics that allow you to create calculations that use multiple data sources. 

Server Prerequisites and Licensing Considerations

Required: SharePoint Server 2010 Enterprise, SQL Server 2005 and 2008 are supported options for Excel Services, PerformancePoint Services, and Visio Services. However, SQL Server 2008 R2 64-bit is required for Reporting Services and Power Pivot when integrating with SharePoint 2010.

We will cover the following topics to get complete understanding of the topic:

1.    Understanding and Creating a Business Intelligence Center Site
2.    What is Dashboard Designer
3.    Error….error…error…Configuring the Central Admin
4.    Creating a Data Connection with a SharePoint list
5.    Showing the data and other designer options

Creating and Configuring Your Business Intelligence Center

The Business Intelligence Center is available as a site collection template and as a site template. By default, the Business Intelligence Center site template is not available from the SharePoint 2010 front end when creating a new site, and therefore you must create your Business Intelligence Center as a site collection from SharePoint Central Administration. After the Business Intelligence Center site collection has been created, the Business Intelligence Center site template is available to create subsites that integrate with the site collection. Once created, the new site collection (or site) contains various SharePoint components and has features deployed and activated.


Creating a New Site Collection Using the Business Intelligence Center Site Collection Template:

The following steps walk through the process of creating a new site collection using the Business Intelligence Center template. Complete the following steps to create your Business Intelligence Center:

1. From within SharePoint 2010 Central Administration, click the Create Site Collections link in the Application Management section.
2. Select the web application you want to create the site collection.
3. Provide a name for the site collection (for example, Business Intelligence Center).
4. Select a managed path or use the link provided to generate a new managed path. For this example, the /sites/ managed path is used.
5. Enter the URL for the new site collection (for example, BICenter).
6. Select the Business Intelligence Center template from the Enterprise tab.
7. Enter a primary administrator for the site collection.
8. Optionally, enter a secondary administrator for the site collection.
9. Optionally, select a quota template.
10. Click OK.

Part 2: In-progress with Issue list you may face during the process.