Here’s what I am trying to do. There is an XML file in the “forms” folder of each our SharePoint libraries called “client_LocationBasedDefaults.html” The file contains the column defaults that can be set in Library settings. The the XML looks like this
<MetadataDefaults> <a href="/RestoreTest/App"> <DefaultValue FieldName="FunctionalClass">OPERATIONS</DefaultValue> <DefaultValue FieldName="BusinessUnit">Applications</DefaultValue> </a> <a href="/RestoreTest/App/Advance_Retail"> <DefaultValue FieldName="FileNumber">REST10001-000002</DefaultValue> <DefaultValue FieldName="FileLocationName">Restore Test==Restore Apps==Advance Retail</DefaultValue> <DefaultValue FieldName="ITSystem">Point of Sale</DefaultValue> </a> </MetadataDefaults>
Here is a snippet of PowerShell which I have been experimenting with for a couple of days. I am able to pull out the href information no problem as well as the fieldnames but not the actual defaultvalues for example 'Point of Sale' . I think my knowledge of XML is probably wanting here. Anyway if someone could point me in the right direction I would be really grateful as I have pretty much exhausted my own limited knowledge and examples I have seen on the net don’t seem applicable.
$default = $document.OpenBinary() $encode = New-Object System.Text.ASCIIEncoding [xml]$defaultXML = ($encode.GetString($default)) $content = $defaultXML.metadatadefaults foreach($w in $content.a) { if($w.href){ Write-Host $w.href } }
$content.[xml-tag]
and took for the XML-attribute in you if-statement. But the value can also be stored as a tag-value and not an attribute. So please edit your question, and add the XML-string you want to read from PowerShell.jref
? Is that right?