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 people picker field for allow only one user/group */
Add-SPUserField -listName $lncustomListName -DisplayName MyList -Name MyList -Required TRUE
/* Method to create people picker field
function Add-SPUserField([string]$listName, [string]$DisplayName, [string]$Name, [string]$Required)
{
$OpenList = $docWeb.Lists[$listName]
$fldXml = "<Field Type='User' DisplayName='"+ $DisplayName +"' 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 people picker field for allow only one user/group */
Add-SPUserField -listName $lncustomListName -DisplayName MyList -Name MyList -Required TRUE
/* Method to create people picker field
function Add-SPUserField([string]$listName, [string]$DisplayName, [string]$Name, [string]$Required)
{
$OpenList = $docWeb.Lists[$listName]
$fldXml = "<Field Type='User' DisplayName='"+ $DisplayName +"' 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