Saturday, June 30, 2012

Site Collection Restore Using powershell from Farm Back UP


Hi,

I am posting power shell script where site collection is getting restored with new configuration from the Farm Back up.

Generally if we write below script to restore site collection, it restores site collection into existing database which is old configuration.

Restore-SPSite -identity $site -path $restorefrom -force -Confirm:$false

Whereas i have put Database, DatabaseServerName, WebApplicationName, SiteUrl in xml file

From xml file power shell script is accessing the values as below.

// RestoreSiteColl.ps1
$snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
if ($snapin -eq $null)
{
Write-Host "Loading SharePoint Powershell Snap-in"
Add-PSSnapin "Microsoft.SharePoint.Powershell"
}
[xml]$xmldata=Get-Content D:\Naga\RestoreSiteCollScript\Test.xml

##[Environment]::CurrentDirectory=(Get-Location -PSProvider FileSystem).ProviderPath
$site = $xmldata.RestoreSiteCollectionInputs.SiteUrl
$restorefrom = $xmldata.RestoreSiteCollectionInputs.Backuppath
$webappurl= $xmldata.RestoreSiteCollectionInputs.WebApplicationName

# get database server and name - prefer to explicitly restore over the existing database
$database = Get-SPContentDatabase -Site $site
if ($database -ne $null)
{
                $dbname = $xmldata.RestoreSiteCollectionInputs.Database
                $dbserver = $xmldata.RestoreSiteCollectionInputs.DatabaseServerName
  New-SPContentDatabase -Name  $dbname -WebApplication $webappurl
                # restore rwebase backup into this new site collection  
                 Restore-SPSite -identity $site -path $restorefrom -force -databasename $dbname -databaseserver $dbserver -Confirm:$false
                write-host "Site Collection Successfully restored" -ForegroundColor Green
}
else
{
                Write-Host "Error: Site '($($site))' must not exist, content database not found. Please ensure the site collection for RWE Home exists and passed as the parameter to this script" -ForegroundColor Red
}

//Test.xml
<?xml version="1.0" encoding="utf-8" ?>
<RestoreSiteCollectionInputs>
  <Database>restoredb43</Database>
  <DatabaseServerName>databaseservername</DatabaseServerName>
  <WebApplicationName>SharePoint - portno</WebApplicationName>
  <SiteUrl>http://servername:portno/sites/samplesite</SiteUrl>
  <Backuppath>D:\SiteCollBackup\backupsite.bak</Backuppath>
</RestoreSiteCollectionInputs>

Wednesday, June 20, 2012

Web Analytics Report Requiremen​t of SharePoint 2010

Hi,

We have a customer, who wants to have following reports in SharePoint 2010,

1.       Report of all access denied response for a particular site.
2.       Report of all users under a particular site
3.       Report of all newly provided access

I have walked thru the report which provided by Web Analytics service

Finally after googling we were able to get the information as below

SharePoint 2010 offers the below reports OOTB,

·         Traffic reports: These reports provide metrics such as:
o   How much traffic your site gets (Number of Page Views);
o   Who visits your sites (Top Visitors);
o   How visitors arrive at your site (Top Referrers);
o   Daily Unique Visitors, Top Destinations, Top Browsers, etc;
·         Search reports: These reports give you insight into what users are searching for, for example:
o   How many times users searched (Number of Queries);
o   What were the most used search terms (Top Queries);
o   What queries have high failure rates (Failed Queries);
o   Best Bet Usage, Search keywords, etc;
·         Inventory reports: These reports display key metrics regarding the inventory of your sites:
o   What is the total disk drive space user (Storage Usage);
o   How many sites exist (Number of Sites);
o   Top Site Product Versions, Top Site Languages, etc;