Update-VaultFile fails to update properties whose display name starts with underscore (_)

Description

When Update-VaultFile -Properties is used to update a property whose display name starts with an underscore (_) it will fail to update that property with the warning 

The entity does not contain a property with the system name '<DisplayName>'

Cause

When you pass a property name to Update-VaultFile cmdlet that starts with an underscore, this property will be interpreted as a system property.

For example 

$updatedFile = Update-VaultFile -File $file._FullPath -Properties @{"_Test" = "Updated" }
would be interpreted as wanting to update a system property "Test", not a user defined property "_Test".

Solution

To get around this you can pass the actual system name of your user defined property. Assume you have a user defined property "_Test" you could get the system name and pass it like this:

$propertyDefinitions = $vault.PropertyService.GetPropertyDefinitionsbyEntityClassId("FILE")
$proptyDefinition = $propertyDefinitions  | Where-Object {$_.DispName -eq "_Test"}
$systemName = $proptyDefinition.SysName
$updatedFile = Update-VaultFile -File $file._FullPath -Properties @{"_$systemName" = "Updated"}