Registers an action to a specifc vault event which gets invoked when the event is raised.

Register-VaultEvent -EventName <String> -Action <Scriptblock> [-SourceIdentifier <string>] [<CommonParameters>]

Type Name Description Default value Optional
VaultEventEventNameThe name of the Vault event to hook up no
Scriptblock / StringActionScriptblock / or functionname that is executed when the event is raised no
StringSourceIdentifierUnique string which represents the registered event, required for unregisternew GUIDyes

Event ← on success
empty ← on failure

The commandlet registers the passed action to a specific vault event. When a vault event is fired, then powerEvents will execute the registered PowerShell action for this event.
Each event is fired when a specific method of the Vault API is called. The information about which event gets triggered for the different calls can be found in the VaultSDK documentation under Web Service Command Event Mappings.

You can hook to 3 different stages for each event, sorted in the sequence they are executed:


Gets raised as first event, even before the Web Service call started and before the Pre event is raised.
Only in here you have the possibility to add restrictions in order to block the upcoming events.


Gets fired after Restrictions and before the actual Web Service call.
If anyone added restrictions for this event (could be even another vault extension), then the Pre event will not get executed.


Gets raised after the Web Service call was executed, no matter if it was successful or not.
Remember, when no Web Service call was executed, neither the Post gets invoked.
The event provides additional information, whether the Web Service call was successful or not. You can use the variable $successful in your PowerShell function.

Item and Change Order events are very special and they may behave different than you think, therefore be sure to know how they behave: Explained here

Registers a function before the State of a file becomes updated:

function Add-Log($files) {
    Write-Host -Object "$($files[0]._Name)"

$event = Register-VaultEvent -EventName UpdateFileStates_Pre -Action "Add-Log"

Write-Host -Object "Registered event with name '$($event.Name)'"

Registers a scripblock when new files become added:

$event = Register-VaultEvent -EventName AddFile_Post -Action {
 param( $file, $parentFolder, $successful)

   if(-not $successful) { return }
    Write-Host -Object "Added file $($file._Name) to the folder '$parentFolder._FullPath'"