Add-VaultMenuItem

Add a Menu Item to a Vault Explorer menu with an Action that is invoked when the menu item is clicked.

Syntax

Add-VaultMenuItem -Location <VaultExplorerMenu> -Name <String> -Action <Scriptblock | String> [<CommonParameters>]

Parameters

Type

Name

Description

Default Value

Optional

VaultExplorerMenu

Location

Vault Explorer Menu to be extended with the Menu Item

no

String

Name

Name of the menu item displayed in the Vault Explorer

no

Scriptblock / String

Action

Scriptblock or function with one parameter ($entities) that is executed when the menu item is clicked.

no

VaultExplorerMenu

Enum values:

Name

Description

FileContextMenu

Context menu (right-click menu) for Files

ItemContextMenu

Context menu (right-click menu) for Items

ChangeOrderContextMenu

Context menu (right-click menu) for Change Orders

Warning: Name must be unique

When multiple menu items for the same Location are registered, the Name parameter must have a unique value assigned.
If a menu item with the same Name and the same Location as a other menu item is created, it will be ignored.

Return type

empty

Remarks

The cmdlet can be used to extend the Vault Explorer’s menus with custom Powershell code.

The Scriptblock / function passed as the Action parameter is invoked with an array of powerVault entities as parameter, which holds the entities that were selected in the Vault Client.
Depending on the Location of the menu item, the powerVault objects can be files, items or change orders.

Added menu items are grouped into a sub-menu named “powerJobs Client”.
Menu items created by the cmdlet are not permanent, when the Vault Client is restarted the menus are reset to their orignal state.
The Menu items cannot be removed or updated once they have been added.

Note

The cmdlet can only be used when running directly in a Vault Explorer Process

Examples

Adds a menu item to the File context menu to queue a DWF job if the file type is supported:

function SubmitDWFJob($entities){
    foreach($file in $entities){
        if($file._Extension -in @('iam', 'ipt', 'ipn', 'idw', 'dwg', 'dxf', 'rvt', 'rfa', 'rte', 'nwd', 'nwf', 'nwc', 'ifc')){
            Add-VaultJob -Name "Autodesk.Vault.DWF.Create.$($file._Extension)" -Parameters @{'FileVersionId' = $file.Id} -Priority 10
        }else{
            [System.Windows.Forms.MessageBox]::Show("File extension '$($file._Extension)' is not supported!")
        }
    }
}
Add-VaultMenuItem -Location FileContextMenu -Name 'Queue DWF job' -Action 'SubmitDWFJob'

Adds a menu item to the Item context menu to queue the powerPLM (powerFLC)Sample.TransferItemBOMs’ job:

Add-VaultMenuItem -Location ItemContextMenu -Name "Transfer Item BOM to FLC" -Action {
    param($entities)
    foreach($item in $entities){
        Add-VaultJob -Name "Sample.TransferItemBOMs" -Parameters @{"EntityId"=$item.Id;"EntityClassId"="Item"} -Description "Transfer Item BOMs for: $($item._Number)"
    }
}