Hi,
I have 15 subsites and one list,I want this list in 15 subsites. Can you give me the procedure.
Hi Kumar,
Good Morning,Thank you for replying.
Thanks,
Manju
Create list template,deploy list template using module and use Web scope feature receiver to and create list.
http://asharepointsolutions.blogspot.in/2013/04/deploy-sharepoint-2010-list-template.html
Thanks for your reply,but I want this code in object model,help me if any.
Use powershell cmdlet
Here is a snippet:
Add-PSSnapin
Microsoft.SharePoint.PowerShell
-ErrorAction
SilentlyContinue
#Function to copy List or Library from One SharePoint site to another
Function CopyList[string]
$SourceWebURL
, [string]
$TargetWebURL
, [string]
$ListName
, [string]
$BackupPath
)
{
#Get the Source List
$SourceList
=(Get
-SPWeb
$SourceWebURL
).Lists[
$ListName
]
#Export the List from Source web
Export
-SPweb
$SourceWebURL
-ItemUrl
$SourceList
.DefaultViewUrl
-IncludeUserSecurity
-IncludeVersions
All
-path
(
$BackupPath
+
$ListName
+
".cmp"
)
-nologfile
-Force
#Import the List to Target Web
import
-spweb
$TargetWebURL
-IncludeUserSecurity
-path
(
$BackupPath
+
$ListName
+
".cmp"
)
-nologfile
-UpdateVersions
Overwrite
}
#Get All List Names
$Lists
= @($(Get
-SPWeb
$SourceWebURL
).lists)
foreach
(
$List
in
$Lists
)
{
#Leave the Hidden Lists and exclude certain Libraries
if(
$List
.Hidden
-eq
$false
-and
$List
.Title
-ne
"Style Library"
-and
$List
.Title
-ne
"Site Pages"
)
{
#Call the function to copy
}
}
Write-Host
"Completed Copying Lists!"
Hope this will help you.