SharePoint Tips, Expert Advice, Forums and Resources

Today's Expert Tip

Add Text Field to a List

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()

Twitter This Tip! ReTweet this Tip!

Idera SharePoint Reviews SMBology, Inc. Rackspace Hosting Sponsored by Idera and SharePoint Reviews and SMBology and EPCGroup.net
Copyright 2011 SecretsOfSharePoint.com. All rights reserved.