Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sharepoint 2013 如何使用PowerShell将SharePoint加载项列表的多行字段更新为增强的RichText_Sharepoint 2013_Sharepoint Apps_Enhanced Rich Text - Fatal编程技术网

Sharepoint 2013 如何使用PowerShell将SharePoint加载项列表的多行字段更新为增强的RichText

Sharepoint 2013 如何使用PowerShell将SharePoint加载项列表的多行字段更新为增强的RichText,sharepoint-2013,sharepoint-apps,enhanced-rich-text,Sharepoint 2013,Sharepoint Apps,Enhanced Rich Text,我在SharePoint Online的SharePoint加载项中有一个列表列,它是一个多行富文本字段。我想使用powershell将其转换为增强富文本字段 $URL、$Username、$password和$ListTitle作为参数传递给编写此代码的函数 try { $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) $ctx.Credentials = New-Object Microsoft.S

我在SharePoint Online的SharePoint加载项中有一个列表列,它是一个多行富文本字段。我想使用powershell将其转换为增强富文本字段

$URL、$Username、$password和$ListTitle作为参数传递给编写此代码的函数

try
{
    $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url)
    $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password)
    $ctx.Load($ctx.Web)
    $ctx.ExecuteQuery()
    $ll=$ctx.Web.Lists.GetByTitle($ListTitle)
    $ctx.Load($ll)
    $ctx.ExecuteQuery()
    #Add new field to the list
    Write-Host "`nGot List" $ListTitle

    $fieldColl = $ll.Fields;

    $isDescriptionPlainText = $false;
    $ctx.Load($fieldColl);
    $ctx.ExecuteQuery();
    foreach ($item in $fieldColl) 
    {
        if($item.InternalName -eq "VisualDescription")
        {

            if($item.InternalName -eq "VisualDescription" -and $item.RichText -eq $false)
            {
                Write-Host ("`n'{0}' Field available.Making Rich Text"-f $item.InternalName)
                $msg=("`n'{0}' Field available.Making Rich Text"-f $item.InternalName)
                writeToLog $msg
                $isDescriptionPlainText=$true;
                $item.RichText = $true
                $item.update()
            }
            else
            {
                Write-Host ("`n Field not available or already a rich text.")
                $msg=("Field not available or already a rich text.")
                writeToLog $msg
            }
        }           
    }
    if($isDescriptionPlainText)
    {
        $ll.update()
        $ctx.Load($ll)
        $ctx.ExecuteQuery()
    }
}
catch
{
    $errorMessage = $_.Exception.Message
    $errLineNumber = $_.InvocationInfo.ScriptLineNumber
    $errOffset = $_.InvocationInfo.OffsetInLine
    $msg = "The script failed due to an unexpected error. [Reason]: $errorMessage [Error Line Number]: $errLineNumber ($errOffset)"
    writeErrorToLog $msg
    # Log the entire stack trace
    writeErrorToLog $_.Exception
    Write-Error $msg
}

我无法使用
$item.RichTextMode=“FullHtml”
,因为
RichTextMode
属性不存在
$item

经过几天的努力,我终于能够解决使用PowerShell将SharePoint加载项列表的多行字段更新为增强型RichText的问题

我们需要更改字段的SchemaXML属性,并将
RichTextMode
Compatible
替换为
FullHtml

$item.SchemaXml=$item.SchemaXml.Replace("RichTextMode=`"Compatible`"","RichTextMode=`"FullHtml`"")

请提供您的代码,您到目前为止尝试了什么。添加了我到目前为止尝试过的代码