From Secrets of SharePont – Tip of the Day
You can use Windows PowerShell to add Text fields to a List in SharePoint 2010. Simply use the Add() method available on a fieldcollection. The example below demonstrates how to add a Text field to the Tasks list, set a Description and set the field as required. Note that the Add() method allows us to specify the Fields Name, the Type of Field and a Boolean value that determines if the field should be required.
| PS > $spWeb = Get-SPWeb http://SP01.powershell.nu
PS > $spList = $spWeb.Lists["Tasks"] PS > $spList.Fields.Add(“Text Field”,”Text”,$true) PS > $spList.Fields[“Text Field”].Description = “My Custom Text Field” PS > $spList.Fields[“Text Field”].Update() PS > $spWeb.Dispose()
|





