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["ExtSiteUrl"].Title = "External Site Url"
 #$spList.Fields["ExtSiteDescription"].Title = "External Site Description"


Do you try to use something like this?

$spField = $spList.Fields["FieldName"]
$spTextField = $spField -as [Microsoft.SharePoint.SPFieldText]
$spTextField.MaxLength = 128
| 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. – Luis Valencia Mar 5 '12 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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