powerVault – Vault API made simple

2015-04-03_10-06-39

The first time we blogged about PowerShell was back in March 2012 (3 years ago). It was unknown in the Autodesk Data Management scene. Meanwhile it’s become quite popular.

With Vault 2015 R2 we took the next step for making the Vault API even more accessible. We created powerVault!

It’s a native PowerShell extension that allows you to talk with Vault via pure PowerShell command lets. With powerVault, you get command lets for dealing with files and items. For instance Open-VaultConnection for establishing a connection to Vault, or Get-VaultFile for getting/downloading a file, or Get-VaultItem for getting an item. But also Add-VaultFile or Update-VaultFile or Update-VaultItem. Such command lets make it very easy to either get information from Vault or creating and updating information in Vault. You don’t have to deal with the complexity of the Vault API, instead you can just execute the command you like and let the command let do the rest for you. As an example:

Import-Module powerVault

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

$CatchAssembly = Add-VaultFile -From "C:\Users\Publ... ...semblies\Catch Assembly.iam" -To "$/Designs/Assemblies/PadLock/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 "C:\Users\Publ... ...ssemblies\Combo Assembly.iam" -To "$/Designs/Assemblies/PadLock/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 "C:\Users\Publ... ...ssemblies\Pad Lock.iam" -To "$/Designs/Assemblies/PadLock/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')

The first line imports the powerVault into your PowerShell session (Import-Module powerVault). With the next few lines we connect to Vault (Open-VaultConnection), we add 3 files to Vault (Add-VaultFile) and then we update those files with properties and set the category. The Add-VaultFile command let creates the folder in Vault, if not existing, and handles check-out/-in in case a file already exists. The last Update-VaultFile also sets the references between the main assembly and the two sub assemblies. And why not even release the files:

$CatchAssembly = Update-VaultFile -File $CatchAssembly.'Full Path' -Status "Released"
$ComboAssembly = Update-VaultFile -File $ComboAssembly.'Full Path' -Status "Released"
$padLock = Update-VaultFile -File $padLock.'Full Path' -Status "Released"

As you can see, with single lines of codes and some readable options, you can import and update files into Vault. In a similar way you can get a file object with Get-VaultFile like this

$file = Get-VaultFile -File "$/Designs/Assemblies/PadLock/Pad Lock.iam"

You will notice that the $file object exposes already all the file properties, so you can access the title just by $file.Title, or to the $file.’Engr Approved By’ or $file.’File Name (Historical)’. Yes, the property names are exactly as exposed in Vault, including blank spaces and brackets. In such cases the property name must be set in quotes (‘…’).

Now, let’s download the assembly into a local folder

Get-VaultFile -File "$/Designs/Assemblies/PadLock/Pad Lock.iam" -DownloadPath c:\temp\padlock

You will notice that the assembly including children will be downloaded and the references will be redirected, so it’s ready to be opened!

And what if you like to get all files of a given folder?

$files = Get-VaultFiles -Folder "$/Designs/Assemblies/PadLock"

Or why not making a search in Vault for all the released drawings?

$files = Get-VaultFiles -Properties @{"File Extension"="idw";"State"="Released"}

Meanwhile you should get a feel for the simplicity of powerVault. For those of you who like to use the native API, no problem, as by establishing the connection to Vault (Open-VaultConnection), you get also the variables $vault (complete webservices), $vaultConnection (VDF) and $vaultExplorerUtil. And you are free to mix the command lets with the native Vault API. So, you get the best of both.

There are more command lets and even more will come. The current documentation can be found here http://wiki.coolorange.com/display/powerjobs/Cmdlets, however with 2016 versions (few weeks) we will create a dedicated area for powerVault.

powerVault is part of powerJobs and powerGate, so you can imagine how easy it is to write jobs with powerJobs or customize powerGate. And as powerVault is now a stand alone and free app, you can use it within your Data Standard projects or for stand alone scripts.

You can now download powerVault from here http://www.coolorange.com/en/download.php?product=powerVault

With the 2016 Version, a dedicated web page will come together with the wiki page. But as we are so excited about powerVault, we were not willing to hold this cool thing back for longer.

There is another thing important to be mentioned. Compatibility! As the syntax of powerVault does not change, the scripts you make with 2015 R2, will also work with 2016 and later versions. We will release an according powerVault version for each Vault version, so that you don’t have to care about upgrading your code.

Curious enough?? Get started by downloading powerVault, or if you already have powerJobs or powerGate just start a PowerShell. Have a look into your installed applications, as maybe powerVault is already there.

2015-04-02_08-58-30

Just one remark. As powerVault is built with latest technology (.Net 4), PowerShell on Windows 7 machine still runs with .Net 2 and does not load powerVault in the first place. However, if you start a PowerShell and execute the following lines, the supported .Net framework will be set to latest version.

add hklm\software\microsoft\.netframework /v OnlyUseLatestCLR /t REG_DWORD /d 1
reg add hklm\software\wow6432node\microsoft\.netframework /v OnlyUseLatestCLR /t REG_DWORD /d 1

Restart the PowerShell and you are ready to go.

Have fun!!

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

4 Responses to powerVault – Vault API made simple

  1. scott moyse says:

    Wow! I’m looking overdue spending some serious time with your stuff.

  2. Pingback: powerVault in Action | coolorange

  3. Ven says:

    I am testing ‘Get-VaultFiles’, looks like it’s not getting the files under subfolders.

    Ex: $files = Get-VaultFiles -Properties @{“Category Name” = “test”} -Folder “$/project/test/”

    Any idea?

  4. Tolgay Hickiran says:

    “There are more command lets and even more will come. The current documentation can be found here http://wiki.coolorange.com/display/powerjobs/Cmdlets, however with 2016 versions (few weeks) we will create a dedicated area for powerVault.”

    When i try the link, it sends me to log in and i don’t have an account on coolorange, any help here?

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