Here is the sample that explains the syntax:
Export-SPWeb -Identity “http://sp.dev/subsite” -ItemUrl “/subsite/lists/List Title here”
-path “c:\temp\tempfile.txt”
Some Where Options:
-Identity: full url (absolute) of the site where the list exists
-ItemUrl: relative path of the list from subsite level. Do not forget to include the leading “/”
-path: path of the output file to save the data in. This does not need any extension but I usually give it .txt.
There are lot more additional parameters but above are the minimum for copying a list
To recreate the list in other environment – I used Import-SPWeb command.
#This is the source web that is hosting the lists to move
$sourceWebUrl = "http://source_web"
#This is the destination web, where the lists will be copied to
$destWebUrl = "http://destination_web"
#Location to store the export file
$path = "\\SBMDEBBD27\BackupSP\Demanada\"
#comma delimited list of List Names to copy
$lists = @("list1","list2","list3")
#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 -Identity $sourceWebUrl -ItemUrl ("/lists/" + $list) -IncludeVersions All -path ($path + $list + ".cmp") -nologfile
"Exporting complete."
"Importing " + $destWebUrl + "/lists/" + $list
$ImportInstruccion = import-spweb -Identity $destWebUrl -path ($path + $list + ".cmp") -nologfile
"Importing Complete"
"`r`n`r`n"
}
Export-SPWeb -Identity “http://sp.dev/subsite” -ItemUrl “/subsite/lists/List Title here”
-path “c:\temp\tempfile.txt”
Some Where Options:
-Identity: full url (absolute) of the site where the list exists
-ItemUrl: relative path of the list from subsite level. Do not forget to include the leading “/”
-path: path of the output file to save the data in. This does not need any extension but I usually give it .txt.
There are lot more additional parameters but above are the minimum for copying a list
To recreate the list in other environment – I used Import-SPWeb command.
PowerShell Script automatic export / import multiple lists
#This is the source web that is hosting the lists to move
$sourceWebUrl = "http://source_web"
#This is the destination web, where the lists will be copied to
$destWebUrl = "http://destination_web"
#Location to store the export file
$path = "\\SBMDEBBD27\BackupSP\Demanada\"
#comma delimited list of List Names to copy
$lists = @("list1","list2","list3")
#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 -Identity $sourceWebUrl -ItemUrl ("/lists/" + $list) -IncludeVersions All -path ($path + $list + ".cmp") -nologfile
"Exporting complete."
"Importing " + $destWebUrl + "/lists/" + $list
$ImportInstruccion = import-spweb -Identity $destWebUrl -path ($path + $list + ".cmp") -nologfile
"Importing Complete"
"`r`n`r`n"
}
Comentarios