Export Vault Data to XML

How to generate a XML file based of data from Vault

$file = Get-VaultFile -Properties @{ "Name" = "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