title: Reading InfoPath forms from a library into an XML object using PowerShell
body: <p>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.</p>
  
  <pre><code>$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)
  }
  </code></pre>
  
  <p>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?</p>