使用PowerShell将InfoPath表单从库读取到XML对象中

时间:2013-10-31 16:56:36

标签: xml sharepoint powershell sharepoint-2010 infopath

我有一个简单的脚本,可以从SharePoint文档库更新InfoPath表单中的字段。但是,我无法让它从SharePoint服务器运行。我可以远程运行它,但是当它在服务器上运行时它会失败。

$Path = "\\spsite\sites\subsite\Library\"
$Files = Get-ChildItem $Path | where {$_.extension -eq ".xml"}

foreach($file in $files){
    $xml = New-Object XML
    $xml.PreserveWhitespace = $true
    $xml.Load($file.fullname)
    $xml.myFields.PhoneNumber = "234-5678"
    $xml.Save($file.fullname)
}

我认为它失败的原因是$ Path中的UNC路径。但是,当我尝试使用URL路径时,它也会失败。有谁知道如何从SharePoint服务器连接到SharePoint中的库的文件路径?

1 个答案:

答案 0 :(得分:2)

这是解决这个问题的一个很好的起点。

查看服务器上的Windows桌面体验。在大多数情况下,您的服务器不知道如何处理WebDav,这是SharePoint用于将内容发布为UNC路径。

你会发现它在普通桌面上100%工作,但路径在服务器上会失败。

您可以在Server 2012中使用PowerShell添加功能

    Add-WindowsFeature Desktop-Experience;
    Add-WindowsFeature InkAndHandwritingServices;
带有漂亮照片的

Here is a post。我个人更喜欢这些照片。