Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have the following code to create a list, however I need to increase via powershell the maxlength of one column

$spWeb = Get-SPWeb -Identity http://ost-dev1.ciredev1.local
 $listTemplate = [Microsoft.SharePoint.SPListTemplateType]::GenericList 
 $spListCollection = $spWeb.Lists 
 $spListCollection.Add("ExternalSites","External Sites",$listTemplate)
 $spList = $spWeb.GetList("/Lists/ExternalSites")
 $spFieldType = [Microsoft.SharePoint.SPFieldType]::Text 
 $spList.Fields.Add("ExtSiteUrl",$spFieldType,$false)
 #$spList.Fields["ExtSiteUrl"].Title = "External Site Url"
 $spList.Fields.Add("ExtSiteDescription",$spFieldType,$false)
 #$spList.Fields["ExtSiteDescription"].Title = "External Site Description"

 $spList.Update()
share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

Do you try to use something like this?

$spField = $spList.Fields["FieldName"]
$spTextField = $spField -as [Microsoft.SharePoint.SPFieldText]
$spTextField.MaxLength = 128
$spTextField.Update()
share|improve this answer
1  
it doesnt work with text fields, apparently the field text is only maximum 255 chars, when I changed to Note, it works pretty well. –  L.V. Sharepoint Architect Mar 5 '12 at 10:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.