Home > PowerShell, SharePoint > Create a list in all the sites using Powershell

Create a list in all the sites using Powershell


Here is way to create a list based on a custom template using Powershell. The script will go through each site and create the list and add them to the Quick Launch


$GetSites = Get-SPWebApplication | Get-SPSite | Get-SPWeb -Limit ALL
foreach($getsite in $GetSites)
{
$listTemplate = $getsite.Site.GetCustomListTemplates($getsite)
$getsite.Lists.Add("MyList","My List",$listTemplate["MyTemplate"])
$list = $getsite.Lists["MyList"]
$list.OnQuickLaunch = $true
$list.Update()

}

Make sure that custom template is uploaded in the List Template Gallery. Check out this link  if you want to add a list template using powershell

Advertisements
  1. September 28, 2011 at 8:35 pm

    usefull information, thanks. hope you add some more posts soon.

  2. Jason
    March 15, 2012 at 2:05 am

    Note that if your root website in SharePoint 2010 is a Records Center, creating custom templates will fail.

    More information:
    http://social.msdn.microsoft.com/Forums/ar/sharepoint2010general/thread/c5455a27-360a-465c-91d5-f81beeac6789
    http://sharepointrecordsmanagement.com/2011/02/

  1. December 8, 2011 at 8:48 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: