This is an example demonstrating how to use our powerful mapping feature in PowerShell. You can use this feature to map Users and Groups, Properties, Content Types, Permission Levels and Site Templates.
- Click PowerShell from the lower-left menu in the Sharegate app.
- You can launch a PowerShell Window and type Import-Module Sharegate.
- First you need to create a new set of mapping settings that will be used later for the copy. To do so, execute the New-MappingSettings command and store the result in a variable.
$mappings = New-MappingSettings
If you check to content of the variable mappings so far you should have an empty set of mappings
$mappings PropertyMappings : ContentTypeMappings : UserAndGroupMappings : PermissionLevelMappings : SiteTemplateMappings :
- Now you can create a property mapping that will be applied to all the lists in my site during the copy if the properties mapped are available (see Set-PropertyMapping).
Set-PropertyMapping -MappingSettings $mappings -Source PropertyA -Destination PropertyB PropertyMappings : PropertyA -> PropertyB ContentTypeMappings : UserAndGroupMappings : PermissionLevelMappings : SiteTemplateMappings :
Note that all Sharegate mapping commands return the resulting mapping settings object, so you can easily pipe all the commands or simply see the result after each command.
- We are now ready to copy our site with these mappings, so all PropertyA columns will be mapped to PropertyB columns in every list that has these columns defined.
$srcSite = Connect-Site -Url http://myfarm1/sites/mysourcesite $dstSite = Connect-Site -Url http://myfarm2/sites/mydestinationsite $result = Copy-Site -Site $srcSite -DestinationSite $dstSite -Merge -MappingSettings $mappings $result Export-Report $result -Path C:\MyReports\CopySiteReports.xlsx Report exported with success to: C:\MyReports\CopySiteReports.xlsx