Tuesday 22 September 2015

Move Lists and Libraries from one site collection to another

.bat file

cd /d %~dp0
powershell -noexit -file    ".\MoveListsandLibrariesfromSC.ps1" "%CD%"
pause

.ps1 file

$ErrorActionPreference = "Stop"

Add-PSSnapin Microsoft.SharePoint.PowerShell
$SourcesiteCollectionUrl = read-host "Enter the source SiteCollection URL"
$TargetSiteCollectionUrl = read-host "Enter the target SiteCollection URL"
$dataFileName = read-host "Enter the data file name to create in C Drive"
$path = "C:\"+$dataFileName+".dat"
Export-SPWeb -identity $SourcesiteCollectionUrl -path $path

Import-SPWeb -identity $TargetSiteCollectionUrl -path $path


Remove-PSSnapin Microsoft.SharePoint.PowerShell

No comments:

Post a Comment