I am currently trying to read the metadata from an index server export with PowerShell to be able to tag a SharePoint document library with this information.
First I search all XML files in the current directory:
$XMLPaths = Get-ChildItem -Recurse -Filter *.xml
Afterwards I get data content from each XML file:
foreach($xmlFile in $xmlPaths) {
[xml]$xmlData = Get-Content -LiteralPath $xmlFile.FullName
...
}
when executing the script I get the Error message "There is no object in the specified path, or it was filtered by the parameters "-Include" or "-Exclude".
Get-Content : Im angegebenen Pfad C:\Users\...\1 Correspondence ZK12\2017\20170623 - CUSTOMER INVOICING - Re_
[Ticket#2017061510027357] [Ticket#2017061610029362] Invoice 80000066607 AF assistance March 17.msg.xml
ist kein Objekt vorhanden, oder es wurde durch die Parameter "-Include" oder "-Exclude" gefiltert.
Since this only occurs with .msg.xml-files, I assume it may be due to non-breaking space or similar chars in the filenames.
Nevertheless, I am surprised that this information seems to be lost between the commands Get-ChildItem
and Get-Content
.
Any suggestions on how I could fix this problem?