Unregister-VaultEvent
Unregisters Vault API events or Vault Client Tab actions so that the registered actions are no longer invoked when the events are raised.
Syntax
Unregister-VaultEvent [-EventName <String>] [-SourceIdentifier <string>] [<CommonParameters>]
Parameters
Type |
Name |
Description |
Optional |
---|---|---|---|
EventName |
The name of the Vault event from which to unregister |
yes |
|
String |
SourceIdentifier |
Unregister a specific registration by specifying it’s SourceIdentifier |
yes |
Return type
Event[] ← on success
empty ← on failure
Remarks
The Cmdlet unregisters either specific or all vault events and returns the unregistered events as a result.
That means, when a specific vault event is raised, the registered VaultEvent will not be executed any more.
To unregister a specific registration the result from the Register-VaultEvent cmdlet can be used to detach the registration via its SourceIdentifier.
When all registrations should be detached from a specific vault event, only the EventName of the Vault event can be used.
Additionally it is possible to unregister from all Vault API events, Vault Client Tab actions and Menu item Actions by not specifying any parameters.
Examples
Unregister from a specific registration:
$event = Register-VaultEvent -EventName UpdateFileStates_Post -Action { param($files) }
Unregister-VaultEvent -SourceIdentifier $event.SourceIdentifier
Unregister from the registration after the State of a file become updated:
Register-VaultEvent -EventName UpdateFileStates_Post -SourceIdentifier 'AddLog_on_UpdateFileStatesPost' -Action "Add-Log"
function Add-Log($file) {
Write-Host -Object "$($file._Name)"
Unregister-VaultEvent -SourceIdentifier 'AddLog_on_UpdateFileStatesPost'
}
Unregisters all the registrations from the AddFile_Post event:
Register-VaultEvent -EventName AddFile_Post -Action {
param( $file )
Write-Host -Object "Added file $($file._Name)"
}
function DoNothing($file) {}
Register-VaultEvent -EventName AddFile_Post -Action "DoNothing"
Unregister-VaultEvent -EventName AddFile_Post
Unregisters all event, tab action and menu item action registrations:
Register-VaultEvent -EventName EditItems_Restrictions -Action { ; }
Register-VaultEvent -EventName UpdateFileStates_Post -Action { ; }
Register-VaultEvent -EventName MoveFile_Pre -Action { ; }
Add-VaultTab -Name "File Tab" -EntityType 'File' - Action { ; }
Add-VaultTab -Name "Item Tab" -EntityType 'Item' - Action { ; }
Add-VaultMenuItem -Location ToolsMenu -Name 'Tools menu item' -Action { ; }
Unregister-VaultEvent