Skip to content

Instantly share code, notes, and snippets.

@VibhuKuchhal
Last active May 29, 2018 00:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VibhuKuchhal/98566c6d822df4bf06c32789d87a1e8a to your computer and use it in GitHub Desktop.
Save VibhuKuchhal/98566c6d822df4bf06c32789d87a1e8a to your computer and use it in GitHub Desktop.
Import-Module Sharegate
#Get credentials from user
$credentials = Get-Credential -UserName migrationuser@yoursharepointtenant.onmicrosoft.com -Message 'Provide 0365 credentials'
#Sharepoint site root path
$migrationRoot = 'https://yoursharepointtenant.sharepoint.com/sites/'
function Migrate-List{
Param(
[System.Management.Automation.CredentialAttribute()] $Credentials,
[string] $SiteName,
[string] $LibName,
[string] $SourceFolder,
[bool] $MigrationAlldata
)
#Assuming site and dstination library is pre created. Creation may be automated as well as if required
$url = $migrationRoot + $siteName
$dstSite = Connect-Site -Url $url -Credential $Credentials
$dstList = Get-List -Site $dstSite -name $LibName
# Introduce Migration Templates
$propTemplate = Import-PropertyTemplate -Path '\\ServerName\C$\Automationdata\templates\BlogFilteredTemplate.sgt' -List $dstList -Overwrite
$templateName = "BlogFilteredTemplate"
if($MigrationAlldata)
{
$propTemplate = Import-PropertyTemplate -Path '\\ServerName\C$\Automationdata\templates\BlogAllDataTemplate.sgt' -List $dstList -Overwrite
$templateName = "BlogAllDataTemplate"
}
$result = Import-Document -DestinationList $dstList -SourceFolder $sourceFolder -TemplateName $templateName
$result
}
# Initiate migration invocation example- filtered data
Migrate-List -Credentials $credentials -SiteName 'destinationSite' -LibName 'Documents' -SourceFolder '\\NetworkShare\sourceFolder' -MigrationAlldata $false
# Initiate migration invocation example - All data
Migrate-List -Credentials $credentials -SiteName 'destinationSite' -LibName 'Documents' -SourceFolder '\\NetworkShare\sourceFolder' -MigrationAlldata $false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment