powerVault in Action

 

In the last post, we presented powerVault, a simplified Vault API for PowerShell. We just released a small video that gives you an overview about powerVault, with some interesting examples. The samples shown in the video are posted in this blog.

powerVault can be installed in 3 ways. Either as stand alone, and here you can download it, or it comes via powerJobs or powerGate. Once powerVault is installed, you can fire up any PowerShell editor and via

Import-Module powerVault

and load the PowerShell command-lets. In case of powerJobs, the command-lets are automatically loaded in the context of the job. If you like to use powerVault stand alone or within Data Standard, then you have to load them one time.

In case you use powerVault inside a PowerShell editor or as a stand alone script, you will need to open a connection to Vault, like this

Open-VaultConnection -Server "localhost" -Vault "Vault" -User "Administrator" -Password ""

In case of Data Standard or powerJobs, the system behind already opened the connection to Vault, so no further login is needed.

In the video, we show as first example how to search for files inside Vault via the Get-VaultFiles and providing one or more properties to search on. If the –Folder argument is omitted, the search goes over the whole Vault, if the –Folder is set, the search is limited to that folder and sub folders.

$files = Get-VaultFiles -Properties @{"Category Name"="Base";"Provider"="Inventor"} -Folder "$/Designs/Assemblies/Metal Container"
$files | ForEach-Object {
  Update-VaultFile -File $_.'Full Path' -Category "Engineering" -Properties @{"Company"="coolOrange"} -Comment "powerVault is cool!"
}

For the files found, you can for instance update them and set the category, the properties, the state, etc.

As a second example we show how to search for released files and export the list as a CSV:

$files = Get-VaultFiles -Properties @{"State"="Released"}
$files | Select-Object Name, 'Category Name', 'Date Modified', 'Current Owner' | Export-Csv "c:\temp\releasedVaultFiles.csv" -Delimiter ';'

In the forth sample, we show how you can use powerVault to play with the Vault API and get a feel for it. Here we move a file from one folder to another, and in order to learn which commands are needed, we use the vapiTrace to trace the Vault API commands and then mimic the behavior in PowerShell.

We first get the file via Get-VaultFile by passing the fill Vault path. Then we get the Vault folder object via the Vault API using the $vault variable, which is set to the Vault service manager and exposes all the services. And then we use the MoveFile from the DocumentService for moving the file.

$file = Get-VaultFile -File "$/coolOrange/100006.ipt"
$fileDWF = Get-VaultFile -File "$/coolOrange/100006.ipt.dwf"
$sourceFolder = $vault.DocumentService.GetFolderByPath($file.Path)
$targetFolder = $vault.DocumentService.GetFolderByPath("$/Designs")
$vault.DocumentService.MoveFile($file.MasterId, $sourceFolder.Id, $targetFolder.Id)

As further sample, we import files from the disc into Vault and update the category, the properties, and set the references between the files.

$sourcepath = "C:\Users\Public\Documents\Autodesk\Vault Professional 2015 R2\Samples\Inventor 2015\Padlock\Designs\Padlock\Assemblies"
$CatchAssembly = Add-VaultFile -From "$sourcepath\Catch Assembly.iam" -To "$/powerVault/Catch Assembly.iam" -FileClassification "Inventor" -Comment "Imported via powerVault"
$CatchAssembly = Update-VaultFile -File $CatchAssembly.'Full Path' -Properties @{"Title"="Catch Assembly"; "Company"="coolOrange"} -Category "Engineering"
$ComboAssembly = Add-VaultFile -From "$sourcepath\Combo Assembly.iam" -To "$/powerVault/Combo Assembly.iam" -FileClassification "Inventor" -Comment "Imported via powerVault"
$ComboAssembly = Update-VaultFile -File $ComboAssembly.'Full Path' -Properties @{"Title"="Combo Assembly"; "Company"="coolOrange"} -Category "Engineering"
$padLock = Add-VaultFile -From "$sourcepath\Pad Lock.iam" -To "$/powerVault/Pad Lock.iam" -FileClassification "Inventor" -Comment "Imported via powerVault"
$padLock = Update-VaultFile -File $padLock.'Full Path' -Properties @{"Title"="Pad Lock"; "Company"="coolOrange"} -Category "Engineering" -AddChilds @($CatchAssembly.'Full Path',$ComboAssembly.'Full Path')

We also show how you could download a complete assembly with all components, with just one command.

$file = Get-VaultFile -File "$/powerVault/Pad Lock.iam" -DownloadPath "c:\temp\powerVault"

During the video, you will have a short view of the $file object that comes back, which exposes all the file properties, so that all you need is already there. Beyond the functions on files, powerVault also offers some first functions on items, such as Get-VaultItem, Get-VaultItemBOM and Update-VaultItem. Over the next months we will add more command-lets and we will keep the compatibility with current and future Vault versions, so that scripts based on these command-lets will run also in the future.

We hope you enjoy powerVault and the video!

This entry was posted in Data Standard, PowerShell, powerVault, Vault API. Bookmark the permalink.

2 Responses to powerVault in Action

  1. Pingback: 2016 is here! | coolorange

  2. Tolgay Hickiran says:

    I couldn’t find vapitrace. Where is it located?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s