Wednesday, May 29, 2019

Duplicate Site Collection

Steps to Duplicate Site Collection in Backup in Same Web Application
==================================================

Step1:
Create Empty Site Collection

Step2:
Create Empty Database

Step3:
Add Database as Content DB

Step4:
Mount Database to Created Site Collection

Add Content Database
stsadm -o addcontentdb -url http://server:port/ -databasename WSS_Content_New -assignnewdatabaseid  -databaseserver  yourdatabaseserver

Step5:
Restore the Backup File to newly created Site Collection
Backup-SPSite -Identity http://server:port/ -path D:\Portal_05May2013.bak
Restore-SPSite -Identity http://server:port/ -path D:\Portal_10Jun2014.bak -force


Mount-SPContentDatabase "<ContentDb>" -DatabaseServer "<DbServer>" -WebApplication http://SiteName

Generate Document info Report

[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
[System.Reflection.Assembly]::Load("Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
[System.Reflection.Assembly]::Load("Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
[System.Reflection.Assembly]::Load("System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")

function Get-DocInventory([string]$siteUrl) {
$site = New-Object Microsoft.SharePoint.SPSite $siteUrl
foreach ($web in $site.AllWebs) {
foreach ($list in $web.Lists) {
if ($list.BaseType -ne “DocumentLibrary”) {
continue
}

foreach ($item in $list.Items) {
$data = @{
"Site" = $site.Url
"Web" = $web.Url
"list" = $list.Title
"Item ID" = $item.ID
"Item URL" = $item.Url
"Item Title" = $item.Title
"Item Created" = $item["Created"]
"Item Modified" = $item["Modified"]
"Created By" = $item["Author"]
"Modified By" = $item["Editor"]
"File Size" = $item.File.Length/1KB
"File Size (MB)" = $item.File.Length/1MB
}
New-Object PSObject -Property $data
}
}
$web.Dispose();
}
$site.Dispose()
}

Get-DocInventory "http://sp2013" | Out-GridView
Get-DocInventory "http://sp2013" | Export-Csv -NoTypeInformation -Path "c:\Document_Detail_Report.csv"

Get Attached Event Receivers for List in On Premises

Add-PSSnapin Microsoft.Sharepoint.Powershell

$site = Get-SPSite -Identity "http://SiteURL"
$web = $site.RootWeb
$list = $web.Lists["test"]
$list.EventReceivers | Select assembly, name, type

Dashboard in Sharepoint

# Add SharePoint cmdlets reference
Add-PSSnapin "Microsoft.SharePoint.Powershell" -ErrorAction SilentlyContinue

#Enable Dashboard
$contentSvc = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$devDahsboardSettings = $contentSvc.DeveloperDashboardSettings
$devDahsboardSettings.DisplayLevel = "On"
$devDahsboardSettings.Update()

#Disable Dashboard
$contentSvc = ([Microsoft.SharePoint.Administration.SPWebService]::ContentService)
$devDahsboardSettings =$contentSvc.DeveloperDashboardSettings
$devDahsboardSettings.DisplayLevel = [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::Off
$devDahsboardSettings.Update()