none
PowerShell script: To copy list columns/column types from an existing list and create a new list with exactly same column names and field types? RRS feed

  • Question

  • Hi there

    Does someone has a PowerShell script:
    That can copy list columns/column types from an existing list and create a new list with exactly same column names and field types?

    Thanks so much!

    Tuesday, March 7, 2017 12:45 AM

Answers

  • Hi,

    Here  you go

    http://www.sptechlearn.com/2014/11/powershell-script-to-copyreplace-items-from-one-list-to-another-list.html


    Please remember to click Mark as Answer on the answer if it helps you

    • Marked as answer by ran009 Tuesday, March 7, 2017 6:33 PM
    Tuesday, March 7, 2017 6:11 AM
  • Hi

    first you have to save the list as a template

    $site = get-spsite("<YourSite>")
    $web = $site.RootWeb
    
    $list = $web.Lists["<Your List>"]
    $list.SaveAsTemplate(“Template Name”,”Template Title”,”Template Description”,1)

    and next create a new list based on that template

    $listTemplates = $site.GetCustomListTemplates($web)
    $web.Lists.Add("Your new list", "", $listTemplates["ListTemplateName"])

    Let me know if you need more details


    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

    • Marked as answer by ran009 Tuesday, March 7, 2017 6:33 PM
    Tuesday, March 7, 2017 7:22 AM

All replies

  • Hi,

    Here  you go

    http://www.sptechlearn.com/2014/11/powershell-script-to-copyreplace-items-from-one-list-to-another-list.html


    Please remember to click Mark as Answer on the answer if it helps you

    • Marked as answer by ran009 Tuesday, March 7, 2017 6:33 PM
    Tuesday, March 7, 2017 6:11 AM
  • Hi

    first you have to save the list as a template

    $site = get-spsite("<YourSite>")
    $web = $site.RootWeb
    
    $list = $web.Lists["<Your List>"]
    $list.SaveAsTemplate(“Template Name”,”Template Title”,”Template Description”,1)

    and next create a new list based on that template

    $listTemplates = $site.GetCustomListTemplates($web)
    $web.Lists.Add("Your new list", "", $listTemplates["ListTemplateName"])

    Let me know if you need more details


    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

    • Marked as answer by ran009 Tuesday, March 7, 2017 6:33 PM
    Tuesday, March 7, 2017 7:22 AM