Issue

A XML file should be generated based on data from Vault


Solution

$file = PrepareEnvironmentForFile "Catch Assembly.idw"
   
$xmlPath = "C:\Temp\$($file.Name).xml"
   
$entityClassId = $file.'Entity Type ID'
$propDefs = $vault.PropertyService.GetPropertyDefinitionsByEntityClassId($EntityClassId)
$propertyNames = $propDefs | Where { $_.IsSys -eq $false } | Select -ExpandProperty DispName
forEach($propertyName in $propertyNames){
    [hashtable]$properties += @{$propertyName = $file.$propertyName}
}
$output = "<root>`n"
forEach($key in $properties.keys){
    $output += "<$key>$($properties.$key)</$key>".Replace(" ","").Replace("(","").Replace(")","") + "`n"
}
$output += "</root>"
   
$output | Out-File $xmlPath