Pergunta

I have a simple script that updates a field in an InfoPath form from a SharePoint document library. However, I cannot get it to run from the SharePoint server. I can run it remotely, but when it runs on the server it fails.

$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)
}

I believe the reason it fails is the UNC path in $Path. However, when I try using a URL path it fails as well. Does anyone know how to connect to the filepath for library in SharePoint from the SharePoint server?

Foi útil?

Solução

Here is a good starting point to fixing this.

Have a look at Windows Desktop Experience on the server. In most cases you server does not know what to do with WebDav, which is was SharePoint uses to publish content as UNC paths.

You will find that it works 100% form a normal desktop but the path will fail on the server.

You can add the features with PowerShell in Server 2012

    Add-WindowsFeature Desktop-Experience;
    Add-WindowsFeature InkAndHandwritingServices;

Here is a post with pretty pictures. I personally prefer the pictures.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top