Visit my previous post for to create a list through powershell script
Create list using powershell script
*********************************************************************************
$lncustomListName listName
$docSite = new-object Microsoft.SharePoint.SPSite($siteURL)
$docWeb = $docSite.OpenWeb()
/* To create DateTime field for allow only one user/group */
Add-SPDateTimeField -listName $lncustomListName -Name DateTimeFieldName -DisplayName DateTimeFieldName -DateType DateOnly -Required FALSE
/* Method to create people DateTime field */
function Add-SPDateTimeField([string]$listName, [string]$DisplayName, [string]$Name, [string]$Required, [string]$DateType)
{
$OpenList = $docWeb.Lists[$listName]
$fldXml = "<Field Type='DateTime' DisplayName='"+ $DisplayName +"' Format='"+ $DateType +"' Required='"+ $Required +"' Name='"+ $Name +"'/>"
$OpenList.Fields.AddFieldAsXml($fldXml,$true,
[Microsoft.SharePoint.SPAddFieldOptions]::AddFieldToDefaultView)
}
**********************************************************************************
Please let me know if faced any issues.
Create list using powershell script
*********************************************************************************
$lncustomListName listName
$docSite = new-object Microsoft.SharePoint.SPSite($siteURL)
$docWeb = $docSite.OpenWeb()
/* To create DateTime field for allow only one user/group */
Add-SPDateTimeField -listName $lncustomListName -Name DateTimeFieldName -DisplayName DateTimeFieldName -DateType DateOnly -Required FALSE
/* Method to create people DateTime field */
function Add-SPDateTimeField([string]$listName, [string]$DisplayName, [string]$Name, [string]$Required, [string]$DateType)
{
$OpenList = $docWeb.Lists[$listName]
$fldXml = "<Field Type='DateTime' DisplayName='"+ $DisplayName +"' Format='"+ $DateType +"' Required='"+ $Required +"' Name='"+ $Name +"'/>"
$OpenList.Fields.AddFieldAsXml($fldXml,$true,
[Microsoft.SharePoint.SPAddFieldOptions]::AddFieldToDefaultView)
}
**********************************************************************************
Please let me know if faced any issues.
No comments:
Post a Comment