如何使用SharePoint Powershell更新Microsoft.SharePoint.Publishing.Fields.HtmlField的内容 [英] How to update content of Microsoft.SharePoint.Publishing.Fields.HtmlField using SharePoint Powershell

查看:50
本文介绍了如何使用SharePoint Powershell更新Microsoft.SharePoint.Publishing.Fields.HtmlField的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我需要使用PowerShell命令更新Publishing HtmlField的内容。我尝试运行以下PowerShell命令:


[Microsoft.SharePoint.Publishing.Fields.HtmlField] $ fld =                                                  [Microsoft.SharePoint.Publishing.Fields.HtmlField] $ lstItem.Fields.GetFieldByInternalName($ colName)


        $ val = $ lstItem [$ colName]

        $ val = $ val.Replace($ oldValue,$ newValue)

        $ fld.ParseAndSetValue($ lstItem,$ val);


        $ lstItem.SystemUpdate($ false);


运行此命令后,此字段的内容失真,并以文本格式而不是html格式呈现内容。


请建议如何更新此字段值而不影响格式。


谢谢

解决方案

< blockquote>

您好,


请提供有关发布HTML字段的更多信息以供进一步研究。比如,它是一个OOTB列或一个自定义列。


在我的测试中,我更新了Pages中"页面内容"(内部名称是"PublishingPageContent")字段的内容库使用下面的PowerShell并且工作正常。

 


siteUrl =" http:// sp2013 / sites / publish" ;

LISTNAME = QUOT;页"

Hi,

I need to update content of Publishing HtmlField using PowerShell command. I tried to run the following PowerShell command:

[Microsoft.SharePoint.Publishing.Fields.HtmlField]$fld =                                                 [Microsoft.SharePoint.Publishing.Fields.HtmlField]$lstItem.Fields.GetFieldByInternalName($colName)

        $val = $lstItem[$colName]
        $val = $val.Replace($oldValue,$newValue)
        $fld.ParseAndSetValue($lstItem,$val);

       $lstItem.SystemUpdate($false);

After running this command content of this field is distorted and renders the content in text format instead of html format.

Please suggest the way how to update this field value without affecting format.

Thanks

解决方案

Hi,

Please provide more information about the Publishing HTML field for further research. Like, it is a OOTB column or a custom column.

In my test, I update the content of the "Page Content"(internal name is "PublishingPageContent") field in Pages library using the PowerShell below and it working fine.


siteUrl="http://sp2013/sites/publish"


listName="Pages"


这篇关于如何使用SharePoint Powershell更新Microsoft.SharePoint.Publishing.Fields.HtmlField的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆