Interview Questions administrator

Best SharePoint administrator Interview Questions and Answers with topic wise:


Recycle Bin | MMS | ManagedVsCrawledProperties |

Saturday, September 13, 2014

Create sharepoint multi people picker field through powershell script

Visit my previous post for to create a list through powershell script and to create people picker for allow single user/group
Create a new sharepoint list using powershell script
Create a people picker column to allow single user/group

**********************************************************************************
$lncustomListName listName
$docSite = new-object Microsoft.SharePoint.SPSite($siteURL)
$docWeb = $docSite.OpenWeb()

/* To create people picker field for allow mutliple users and groups */

Add-SPUserField -listName $lncustomListName -DisplayName MyList -Name MyList -Required TRUE

function Add-SPMultiUserField([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)
   $fieldname=$OpenList.Fields[$DisplayName]
   $fieldname.AllowMultipleValues=$true
   $fieldname.update()  
}
*********************************************************************************

No comments:

Post a Comment