【问题标题】:Importing CSV with HTML markup in some values using PowerShell使用 PowerShell 在某些值中导入带有 HTML 标记的 CSV
【发布时间】:2013-10-10 18:53:14
【问题描述】:

我有一个 CSV 文件,其中一些值包含我尝试插入 SharePoint 列表的解码 HTML 标记(例如 <b%gt;Example</b%gt;)。

当我使用 PowerShell 遍历值时,无论我做什么,它都会在 , 处拆分字符串。
我尝试用"' 包装字符串,但随后PowerShell 抛出此错误:

更新:使用“0”参数调用“更新”的异常:“无效 文本值。

文本字段包含无效数据。请检查值并尝试 再次。”

在 C:\Scripts\Configuration\SystemConfiguration.ps1:41 字符:22 + $spListItem.update

以下是其中一个值的示例:

"<b>Dear {0} Team,</b><br/>{1} request was completed <a href='{2}'>{3}</a>.<br/><br/>{2}<br/><br/>To download the PDF of the form please click  <a href='{6}'>Here</a>.<br/>In case of questions, please contact {4}.<br/><br/>With best regards<br/><br/>{5}"

谁能给我一些提示如何确保上面的值可以成功插入?

【问题讨论】:

    标签: powershell csv


    【解决方案1】:

    我通过玩弄一些HttpUtility 方法找到了答案。

    $Value = <b>Dear {0} Team,</b><br/>{1} request was completed <a href='{2}'>{3}</a>.<br/><br/>{2}<br/><br/>To download the PDF of the form please click  <a href='{6}'>Here</a>.<br/>In case of questions, please contact {4}.<br/><br/>With best regards<br/><br/>{5}
    [System.Web.HttpUtility]::HtmlDecode($Value)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-07-25
      • 1970-01-01
      • 2021-06-13
      • 2015-11-16
      • 1970-01-01
      • 1970-01-01
      • 2017-09-26
      相关资源
      最近更新 更多