It is possible to use a CSV file to specify multiple source site collections from which we want to export content. A CSV file is a simple type of file that creates a representation of a table using a delimiter like a semi-colon. This file can be opened in Excel which shows the data in a spreadsheet which can then be easily modified using Excel's powerful features. This can then be easily read by PowerShell within a foreach loop. Here is an example where we export the site "Important" from all the sites in the CSV file :
$csvFile = "C:\CSVfile.csv" $table = Import-Csv $csvFile -Delimiter ";" foreach ($row in $table) { $srcSite = Connect-Site -Url $row.SourceSite $dstPath = $row.DestinationPath Export-Site -SourceSite $srcSite -Name "Important" -DestinationFolder $dstPath -Subsites }
The row variable in the loop corresponds to the current row. When the loop is done, we go to the next row and so on. Here what the CSV file looks like for this example :
You can take this example and modify it to your need. For example, you could replace the Export-Site command by the Export-List command and export a list from multiple site collections. This is just a base example which can be used for multiple commands and use cases.
Comments
0 comments
Please sign in to leave a comment.