none
Migrate site collection from SharePoint online to online using Powershell RRS feed

  • Question

  • I want to migrate one site collection of SharePoint online to other SharePoint online environment by using Powershell.

    Kindly advice to achieve this.

    Tuesday, September 12, 2017 11:44 AM

Answers

  • Hi Pranoti_29,

    We need to get the custom site template name using CSOM, then To create site with a custom site template using WebCreationInformation class.

    Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll" 
    
    Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" 
    
    $siteUrl = "https://tenant.sharepoint.com"
    
    $username = "user@tenant.onmicrosoft.com"
    
    $password = Read-Host -Prompt "Enter password" -AsSecureString 
    
     
    
    $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
    
    $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
    
    $ctx.Credentials = $credentials
    
     
    
    #Get Custom Templates
    
    $Templates = $ctx.Site.GetWebTemplates("1033","0")
    
    $ctx.Load($Templates)
    
    $ctx.ExecuteQuery()
    
    $Templates | Where {$_.Name -like "*{*" } | Select Name
    
     
    
    #Create subsite using the custom template
    
    $WCI = New-Object Microsoft.SharePoint.Client.WebCreationInformation
    
    # Use the custom template name
    
    $WCI.WebTemplate = "{13365287-9660-490F-BDCB-F7CF1CE06247}#customT1"
    
    $WCI.Description = "newSubSite"
    
    $WCI.Title = "newSubSite"
    
    $WCI.Url = "newSubSite"
    
    $WCI.Language = "1033"
    
    $SubWeb = $ctx.Web.Webs.Add($WCI)
    
    $ctx.ExecuteQuery()


    For more information, you can refer to the blog below:

    https://blogs.technet.microsoft.com/fromthefield/2015/10/21/create-a-subsite-web-using-a-custom-template-in-sharepoint-online-using-powershell-and-csom/

    Best Regards,

    Linda Zhang


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by MS_User_007 Friday, September 15, 2017 10:20 AM
    Wednesday, September 13, 2017 7:29 AM
    Moderator

All replies

  • i dont think, you can do it due to limitation in SHarePoint online. you best bet is use the 3rd party tool to perform this activity.

    https://www.linkedin.com/pulse/migrating-sharepoint-online-content-between-different-michel-mendes/


    Please remember to mark your question as answered &Vote helpful,if this solves/helps your problem. ****************************************************************************************** Thanks -Waqas Sarwar(MVP) Blog: http://krossfarm.com

    Tuesday, September 12, 2017 12:57 PM
    Moderator
  • I have template of 1 subsite, by using that template can i create subsite in another SharePoint environment by using powershell?

    My requirement is to create subsite using template via powershell.

    Wednesday, September 13, 2017 5:51 AM
  • Hi Pranoti_29,

    We need to get the custom site template name using CSOM, then To create site with a custom site template using WebCreationInformation class.

    Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll" 
    
    Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" 
    
    $siteUrl = "https://tenant.sharepoint.com"
    
    $username = "user@tenant.onmicrosoft.com"
    
    $password = Read-Host -Prompt "Enter password" -AsSecureString 
    
     
    
    $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
    
    $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
    
    $ctx.Credentials = $credentials
    
     
    
    #Get Custom Templates
    
    $Templates = $ctx.Site.GetWebTemplates("1033","0")
    
    $ctx.Load($Templates)
    
    $ctx.ExecuteQuery()
    
    $Templates | Where {$_.Name -like "*{*" } | Select Name
    
     
    
    #Create subsite using the custom template
    
    $WCI = New-Object Microsoft.SharePoint.Client.WebCreationInformation
    
    # Use the custom template name
    
    $WCI.WebTemplate = "{13365287-9660-490F-BDCB-F7CF1CE06247}#customT1"
    
    $WCI.Description = "newSubSite"
    
    $WCI.Title = "newSubSite"
    
    $WCI.Url = "newSubSite"
    
    $WCI.Language = "1033"
    
    $SubWeb = $ctx.Web.Webs.Add($WCI)
    
    $ctx.ExecuteQuery()


    For more information, you can refer to the blog below:

    https://blogs.technet.microsoft.com/fromthefield/2015/10/21/create-a-subsite-web-using-a-custom-template-in-sharepoint-online-using-powershell-and-csom/

    Best Regards,

    Linda Zhang


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by MS_User_007 Friday, September 15, 2017 10:20 AM
    Wednesday, September 13, 2017 7:29 AM
    Moderator
  • Migrate SharePoint Online to different SharePoint Online :
    http://expert-advice.org/2017/01/migrate-sharepoint-online-different-sharepoint-onlineoffice-365-tenants/

    SharePoint Migration to Online (SPO-O365) from On-Premise SharePoint using Azure API as well as Powershell command: https://migrationspo.blogspot.in/2016/06/sharepoint-migration-to-online-spo-o365_20.html

    Use PowerShell to Automate Site Collection Setup in SharePoint Online:
    http://3sharp.com/blog/use-powershell-to-automate-site-collection-setup-in-sharepoint-online/
    Wednesday, September 13, 2017 10:01 AM
  • Thanks Linda for sharing this. It works for me.. can you please tell me how to upload and activate subsite template via powershell in a solution gallery?

    for now, I have manually uploaded and activated the same but it would be helpful if i could do the same via powershell..

    Friday, September 15, 2017 10:19 AM