Save-VaultFile

Downloads a file from Vault to a local directory.

Syntax

Save-VaultFile -File <String> [-DownloadDirectory <String>] [-Version <VersionSelector>] [-ExcludeChildren] [-NoRecursiveChildren] [-NotOverride] [-IncludeAttachments] [-IncludeHiddenEntities] [-IncludeParents] [-RecursiveParents][-IncludeRelatedDocumentation] [<CommonParameters>]

Parameters

Type

Name

Description

Default value

Optional

String

File

VAult Path to the file, which should be downloaded

no

String

DownloadDirectory

Absolute Path to a local directory. If NOT set, it will download the file to the Vault workspace.
If the target directory doesn’t exist it will be created

yes

VersionSelector

Version

Version of the related files to be downloaded.
Possible values are: Latest, Actual and Revision

Latest

yes

SwitchParameter

ExcludeChildren

Children of the source file will be excluded

yes

SwitchParameter

NoRecursiveChildren

Only the first level of children will be included

yes

SwitchParameter

ExcludeLibraryContents

Entities that are a part of a Vault Library will be excluded

yes

SwitchParameter

NotOverride

Folder/Files will not be overwritten, if they already exists

yes

SwitchParameter

IncludeAttachments

Attachments of the file will be included

yes

SwitchParameter

IncludeHiddenEntities

Hidden entities will be included

yes

SwitchParameter

IncludeParents

Parents of the source file will be included

yes

SwitchParameter

RecursiveParents

Parents will be included recursively

yes

SwitchParameter

IncludeRelatedDocumentation

The related documentation of the source file will be included.
For example, a DWG might be considered related documentation for an assembly. The DWG is not considered an attachment or a dependent

yes

Return type

File[] ← on success
empty ← on failure. Exception/ErrorMessage can be accessed using $Error.

Remarks

The cmdlet downloads a file from the Vault Server to a local directory. By default, it also downloads all references and can optionally include attachments.

The result of the cmdlet is a list of all downloaded files.
Each file includes an additional ‘LocalPath’ property that provides the full local path (including the file name) of the downloaded file.

Important: All files downloaded with this cmdlet are marked as read-only in Windows because they are not checked out from Vault. This means you cannot modify or delete them directly!
To delete these files anyway, run Remove-Item $file.LocalPath -Force in PowerShell to bypass the read-only protection.

VersionSelector

Name

Description

Latest

Gathers the actual version for the relationship

Actual

Gathers the latest version

Revision

Gathers the appropriate version that represents the revision for the relationship

Examples

Download a File

$result = Save-VaultFile -File "$/Designs/Sample/Not.iam" -DownloadDirectory "C:\temp\Vault\Sample\"
$result[0].LocalPath #Returns C:\temp\Vault\Sample\Not.iam

Download a File to the vault workspace including related documentation files

$result = Save-VaultFile -File "$/Designs/Sample/Not.iam" -IncludeRelatedDocumentation

Error handling, analyze why file could not be downloaded using $Error

$file = Save-VaultFile -File '$/Restriced/Reatiner.idw' -DownloadDirectory "C:\Temp\Test\Download"

if(-not $file){
    $Error[0].Exception #Returns: "You don't have permission to download the file. Please check the file's permissions in the Details dialog under the Security tab."
}