When using Update-VaultFile to modify attachments an old version of the updated file is checked into Vault

Description

When calling the Update-VaultFile cmdlet with any of the attachment parameters to add an attachment that has any other classification than 'DesignVisualization' it can lead to old versions of the main file to be checked in as the latest version in Vault

Cause

This happens because the main file needs to be downloaded and uploaded again to attach files of any classification than 'DesignVisualization'. To comply with that Update-VaultFile downloads the main file to %temp%.

In some rare cases old versions of the same file are not removed correctly. We are investigating this currently.

Solution

Until a proper fix can be provided it is possible to add a workaround to your scripts.

  • Create a file 'C:\ProgramData\coolOrange\powerJobs\Modules\UpdateVaultFileWorkaround.psm1' for powerJobs Processor or 'C:\ProgramData\coolOrange\Client Customizations\Modules\UpdateVaultFileWorkaround.psm1' for powerJobs Client with
function Remove-TempFile($File) {
      $tempFilePath = Join-Path -Path $env:TEMP -ChildPath $File._Name
      if(Test-Path $tempFilePath) {
        Remove-Item -LiteralPath $tempFilePath -Force -ErrorAction SilentlyContinue
      }
}
  • Now you have to call Remove-TempFile in every script before calling Update-VaultFile with -AddAttachments, -RemoveAttachments, -Attachments

For example:

$null = Update-VaultFile -File $file._FullPath -Attachments @('$/Designs/Test.txt')

to

Remove-TempFile -File $file
$null = Update-VaultFile -File $file._FullPath -Attachments @('$/Designs/Test.txt')