I this article I am going to present you to create multiple SharePoint Custom list instances using PowerShell.It is very helpful when we are working on migrating SharePoint environment.
In below example list name is same as the template which we are uploading to template gallery.
Add-PSSnapin "Microsoft.SharePoint.PowerShell" # Custom template path $Path = "C:\CustomTemplate" # Your site url $oSite = Get-SPSite("htpp://localhost/") # Get the root web $oWeb = $oSite.RootWeb # Get the list template gallery $spLTG = $oWeb.GetFolder("List Template Gallery") # Get the list template gallery Collection $spcollection = $spLTG.files # loop all stp files and upload/create custom list Get-ChildItem $Path -Filter "*.STP" | ForEach-Object { $Templatefile = get-item $_.FullName $catlogs="_catalogs/lt/" + $_.Name $lstDesc="Description :" + $_.BaseName $spcollection.Add($catlogs, $Templatefile.OpenRead(), $true) $CustomlistTemplates = $oSite.GetCustomListTemplates($oWeb) $oWeb.Lists.Add($_.BaseName, $lstDesc, $CustomlistTemplates[$_.BaseName]) Write-Host $_.BaseName+" List has been created" -foregroundcolor green } $oWeb.Dispose() $oSite.Dispose()
It is really nice to see your collection .. It saved my lots of time and manual work.
LikeLiked by 1 person
Thank you so much !!! awesome blog this is what i wanted…
LikeLike