Skip to main content

Register-DMCallback

SYNOPSIS

Registers a scriptblock to be called when invoking any Test- or Invoke- command.

SYNTAX

__AllParameterSets

Register-DMCallback [-Name] <string> [-ScriptBlock] <scriptblock> [<CommonParameters>]

DESCRIPTION

Registers a scriptblock to be called when invoking any Test- or Invoke- command. This enables extending the module and ensuring correct configuration loading. The scriptblock will receive four arguments:

  • The Server targeted (if any)
  • The credentials used to do the targeting (if any)
  • The Forest the two earlier pieces of information map to (if any)
  • The Domain the two earlier pieces of information map to (if any) Any and all of these pieces of information may be empty. Any exception in a callback scriptblock will block further execution!

For more details on this system, call: Get-Help about_DM_callbacks

EXAMPLES

EXAMPLE 1

Register-DMCallback -Name MyCompany -Scriptblock $scriptblock

Registers the scriptblock stored in $scriptblock under the name 'MyCompany'

PARAMETERS

-Name

The name of the callback to register (multiple can be active at any given moment).

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: 0
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-ScriptBlock

The scriptblock containing the callback logic.

Type: System.Management.Automation.ScriptBlock
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: 1
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.