When trying to change a property of type Date of a Vault File using the Update-VaultFile cmdlet, it clears the property or doesn’t correctly


To avoid this problem, define a DateTime object and write your new date as parameter.


Powershell v5 and above:

To change a date property of the file to the 5th of august 2018 and update the Vault file (change <DateTypePropertyName> to the name of the property you want to change):

$day = 5
$month = 8
$year = 2018

$date = [System.DateTime]::new($year, $month, $day)
Update-VaultFile -File $file._FullPath -Properties @{<DateTypePropertyName> = $date}

To update the property with the current date you can use e.g.

$currentDate = Get-date
$updatedFile = Update-VaultFile -File $file._FullPath -Properties @{
    "ModifiedOn" = $currentDate

See Also


Get-Date (MSDN)

DateTime Structure (MSDN)