{"id":8477,"date":"2024-12-19T20:06:29","date_gmt":"2024-12-19T20:06:29","guid":{"rendered":"https:\/\/pariswells.com\/blog\/?p=8477"},"modified":"2024-12-19T20:06:30","modified_gmt":"2024-12-19T20:06:30","slug":"code-to-batch-copy-sharepoint-libraries-in-powershell-and-sharegate","status":"publish","type":"post","link":"https:\/\/pariswells.com\/blog\/research\/code-to-batch-copy-sharepoint-libraries-in-powershell-and-sharegate","title":{"rendered":"Code to Batch Copy Sharepoint Libraries in Powershell and Sharegate"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code class=\"\">Import-Module Sharegate\n$csvFile = \"C:\\Scripts\\Sharepoint.csv\"\n$table = Import-Csv $csvFile -Delimiter \",\"\n\n#$mappingSettings = New-MappingSettings\n\n\n$srcsiteConnection = Connect-Site -Url https:\/\/xxxxx-admin.sharepoint.com\/ -Browser\n$dstsiteConnection = Connect-Site -Url https:\/\/xxxxx-admin.sharepoint.com\/ -Browser\n\n\nSet-Variable srcSite, dstSite, srcList, dstList\nforeach ($row in $table) {\n Clear-Variable srcSite\n Clear-Variable dstSite\n\n $srcSite = Connect-Site -Url $row.SourceSite  -UseCredentialsFrom $srcsiteConnection\n $dstSite = Connect-Site -Url $row.DestinationSite  -UseCredentialsFrom $dstsiteConnection\n #https:\/\/documentation.sharegate.com\/hc\/en-us\/articles\/360027986731-Copy-options-in-PowerShell\n #https:\/\/documentation.sharegate.com\/hc\/en-us\/articles\/115000640448-Copy-Content\n $copysettings = New-CopySettings -OnContentItemExists IncrementalUpdate\n Copy-Site -Site $srcSite -DestinationSite $dstSite -CopySettings $copysettings\n\n}\n\n\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-8477","post","type-post","status-publish","format-standard","hentry","category-research"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/8477","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/comments?post=8477"}],"version-history":[{"count":1,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/8477\/revisions"}],"predecessor-version":[{"id":8478,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/8477\/revisions\/8478"}],"wp:attachment":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/media?parent=8477"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/categories?post=8477"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/tags?post=8477"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}