Wednesday 6 November 2013

Copy and move SharePoint list from one site to another site using PowerShell

Share it Please
    Copy and move bulk SharePoint site collection list or library from one site to another SharePoint Site using PowerShell Script

    1.Click "Start" button
    2.Choose the "Microsoft SharePoint 2010 Products"
    3.Click the "SharePoint 2010 Management Shell" [ run as Administrator ]


     4.Create one folder in "C" Drive Named it Backup

Script:-


   #Enter your Source Site collection Url
   $sourceWebUrl = "---------"
    
   #this is the destination Site Collection, where the lists will be copied to
   $destWebUrl = "-----------"
    
   #Location to store the export file
   $path = "C:\Backup"
    
   #comma delimited list of List Names to copy
   $lists = @("------ ", "-------")
    
    
   #Loop through the lists, export the list from the source, and import the list into the destination
   foreach($list in $lists)
   {
       "Exporting " + $sourceWebUrl + "/lists/" + $list
    
           export-spweb $sourceWebUrl -ItemUrl ("lists/" + $list) -IncludeUserSecurity -IncludeVersions All -path ($path + $list + ".cmp") -nologfile
    
       "Exporting complete."
    
    
    
       "Importing " + $destWebUrl + "/lists/" + $list
    
           import-spweb $destWebUrl -IncludeUserSecurity -path ($path + $list + ".cmp") -nologfile
    
       "Importing Complete"
       "`r`n`r`n"

   }


Example:-

    
   #Enter your Source Site collection Url
   $sourceWebUrl = "http://Abcd:32033/sites/SampleSite/"
   
   #this is the destination Site Collection, where the lists will be copied to
   $destWebUrl = "http://Abcd:32033/sites/BiSam"
   
   #Location to store the export file
   $path = "C:\ Backup"
   
   #comma delimited list of List Names to copy
   $lists = @("TestList", "TestList1","SampleList")
   
   
   #Loop through the lists, export the list from the source, and import the list into the destination
   foreach($list in $lists)
   {
       "Exporting " + $sourceWebUrl + "/lists/" + $list
   
           export-spweb $sourceWebUrl -ItemUrl ("lists/" + $list) -IncludeUserSecurity -IncludeVersions All -path ($path + $list + ".cmp") -nologfile
   
       "Exporting complete."
   
   
   
       "Importing " + $destWebUrl + "/lists/" + $list
   
           import-spweb $destWebUrl -IncludeUserSecurity -path ($path + $list + ".cmp") -nologfile
   
       "Importing Complete"
       "`r`n`r`n"
   }
 Note :-
  http://Abcd:32033/sites/SampleSite/ =Source site collection Url
  http://Abcd:32033/sites/BiSam  = Destination site collection Url
  TestList,TestList1,SampleList  = List Name

No comments:

Post a Comment

Followers

Follow The Author