Below code will help us to create a SharePoint list through PowerShell:
Thanks,
Sasi kumar Reddy
================================================================================== $siteURL= "your site URL" $ListName ="List Name" $ListName1 ="ListName1" ================================================================================== $docSite = new-object Microsoft.SharePoint.SPSite($siteURL) $docWeb = $docSite.OpenWeb() $TemplateType = $docWeb.ListTemplates["Custom List"] function Create-SPList([string]$listName, [string]$description) { $exLst = $docWeb.Lists[$listName] //Create new list if already doesn't exists if($exLst -eq $null) { Write-Host "`n List does not exist. Creating $listName list`n" [void]$docWeb.Lists.Add($listName, $description, $TemplateType) $docWeb.Update() } } ================================================================================== //To create list name Create-SPList -listName $ListName -description "List Description" Create-SPList -listName1 $ListName1 -description "List Description1" ===================================================================================Please let me know if face any issues while creating list through powershell.
Thanks,
Sasi kumar Reddy
No comments:
Post a Comment