Add-ADTModuleCallback
SYNOPSIS
Adds a callback function to the nominated hooking point.
SYNTAX
Add-ADTModuleCallback [-Hookpoint] <CallbackType> [-Callback] <CommandInfo[]> [<CommonParameters>]
DESCRIPTION
This function adds a specified callback function to the nominated hooking point.
EXAMPLES
EXAMPLE 1
Add-ADTModuleCallback -Hookpoint PostOpen -Callback (Get-Command -Name 'MyCallbackFunction')
Adds the specified callback function to be invoked after a DeploymentSession has opened.
PARAMETERS
-Hookpoint
Where you wish for the callback to be executed at.
Valid hookpoints are:
- OnInit (The callback is executed before the module is initialized)
- OnStart (The callback is executed before the first deployment session is opened)
- PreOpen (The callback is executed before a deployment session is opened)
- PostOpen (The callback is executed after a deployment session is opened)
- PreClose (The callback is executed before the deployment session is closed)
- PostClose (The callback is executed after the deployment session is closed)
- OnFinish (The callback is executed before the last deployment session is closed)
- OnExit (The callback is executed after the last deployment session is closed)
Each hook point supports multiple callbacks, each invoked in the order they're added.
To see a list all the registered callbacks in order, use Get-ADTModuleCallback
.
Type: CallbackType
Parameter Sets: (All)
Aliases:
Accepted values: OnInit, OnStart, PreOpen, PostOpen, PreClose, PostClose, OnFinish, OnExit
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Callback
The callback function to add to the nominated hooking point.
Type: CommandInfo[]
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
INPUTS
None
You cannot pipe objects to this function.
OUTPUTS
None
This function does not generate any output.
NOTES
An active ADT session is NOT required to use this function.
Also see Remove-ADTModuleCallback
about how callbacks can be removed.
Tags: psadt
Website: https://psappdeploytoolkit.com
Copyright: (C) 2025 PSAppDeployToolkit Team (Sean Lillis, Dan Cunningham, Muhammad Mashwani, Mitch Richters, Dan Gough).
License: https://opensource.org/license/lgpl-3-0
RELATED LINKS
https://psappdeploytoolkit.com/docs/reference/functions/Add-ADTModuleCallback