Active Directory Management Framework

Configuration driven Active Directory management.



The Callback system is a way to register a scriptblock that will execute each time any Component is tested or invoked. This allows integrating logic, for example to validate configuration, prompt for user choice or … really anything else you want to trigger off it.

Originally, this was built to ensure the GUI Context prompt executes, when targeting a new domain.

When running one of those commands, all callbacks will sequentially be called. Keep execution time in mind, as this might cause a significant delay in execution, especially when chaining multiple commands! Any uncaught exception in any scriptblock will cause the execution of the Component to fail.

The scriptblocks will each receive four arguments:

Any and all of these pieces of information may be empty.

Commands to manage the callbacks:

Since the domain and forest Categories are implemented in separate, independent modules, each has its own callback handling. However, both implementations are identical.

Example Callback

$callbackScript = {
	param (
	$parameters = $PSBoundParameters | ConvertTo-PSFHashtable -Include Server, Credential
	if ($parameters.Server -eq '<Default Domain>') { $parameters.Server = $env:USERDNSDOMAIN }
	Set-AdmfContext @parameters -Interactive -ReUse -EnableException
Register-DMCallback -Name ADMF -ScriptBlock $callbackScript
Register-FMCallback -Name ADMF -ScriptBlock $callbackScript