Unregister-VaultEvent
Unregisters from vault events, in order that the registered actions do not get invoked any more 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 commandlet unregisters specific (or all) registrations from vault events.
That means, when a specific vault event is raised, the registered powerEvents will not be executed any more.
In order to unregister a specific registration, you need access to the result from the Register-VaultEvent cmdlet, in order to detach the registration via it’s SourceIdentifier.
When all registrations should be detached from a specific vault event, only the EventName of the required Vault event can be used.
Additionally it’s also possible to unregister from all registrations from all Vault events, by not specifying any parameters.
The commandlet returns the unregistered events.
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 the registrations:
Register-VaultEvent -EventName EditItems_Restrictions -Action { ; }
Register-VaultEvent -EventName UpdateFileStates_Post -Action { ; }
Register-VaultEvent -EventName MoveFile_Pre -Action { ; }
Unregister-VaultEvent