1

Below is my code,

param([string]$workspaceUrl)
[Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges(
{
    $site = SPSite($workspaceUrl)
    $web = $site.RootWeb
    $spList = $web.Lists["ListName"]
    $spFieldType = [Microsoft.SharePoint.SPFieldType]::Note
    $spList.Fields.Add("YourColumn",$spFieldType,$false)
    $spList.Update()
})

How can I set the field to multiple lines of text, allowing rich text and unlimited lines of text with powershell?

2

Modify your script like so, and you're good to go:

param([string]$workspaceUrl)
[Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges(
{
    $site = SPSite($workspaceUrl)
    $web = $site.RootWeb
    $spList = $web.Lists["ListName"]
    $spFieldType = [Microsoft.SharePoint.SPFieldType]::Note
    $newFieldName = $spList.Fields.Add("YourColumn", $spFieldType, $false)
    $newField = $spList.Fields.GetFieldByInternalName($newFieldName)
    if ($spList.BaseType -eq "DocumentLibrary") {
        $newField.UnlimitedLengthInDocumentLibrary = $true
    }
    $newField.RichText = $true
    $newField.RichTextMode = "FullHtml" #enables the Ribbon editor
    $newField.Update()
    $spList.Update()
})
5
  • Thanks Mark :) and for removing the number of lines limit? Jul 12 '16 at 8:39
  • I updated my answer. You only need to set the unlimited length in case your list is a document library. If it's just a plain list, the Note field is already unlimited. Jul 12 '16 at 9:00
  • thanks upvoted and accepted answer I saw the number of lines - 6 in the column, wanted to increase that to accommodate more lines Jul 12 '16 at 9:20
  • 1
    "Number of lines" is only used to define the height of the edit box. It doesn't say anything about the number of lines you can put in there. If you like, you can change this as well through PowerShell: $newField.NumberOfLines = 10 Jul 12 '16 at 9:23
  • if possible, please share a link where I can learn these Jul 12 '16 at 11:48

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.