Hello Dmytro,
You will need to bind to the Custom Command, create arguments for the command execution, specify parameter values that will be used to execute the command in the Scheduled Task and then pass the arguments to the Arguments property of the action. Here is the code that will do the trick:
# Define actions and conditions for the task
$commandID = "{a7264a61-b77d-4386-a138-ec2557c5b3ba}" # Command ID
$commandDN = "CN=MyCommand,CN=Custom Commands,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes" # Command DN
# Create action set
$actionsAndConditions = $task.ConditionedActions.Create()
$actionsAndConditions.ConditionsLogicalOperation = "ADM_LOGICALOPERATION_AND"
$actionsAndConditions.SetInfo()
# Create execute Custom Command action
$action = $actionsAndConditions.Actions.CreateEx("adm-CustomCommandAction")
$action.ExecutionOptions = "ADM_ACTIONEXECUTIONOPTIONS_SYNC"
# Get action
$removeAction = $action.GetAction()
# Bind to Custom Command
$customCommand = $Context.BindToObjectByDN($commandDN)
# Specify command arguments
$arguments = $customCommand.CreateArguments()
$arguments.SetParameterValue("MyParameter", "MyValue") # Parameter value
# Configure the action
$removeAction.CustomCommandId = $commandID
$removeAction.Arguments = $arguments
# Save action
$action.SetAction($removeAction)
$action.SetInfo()
In the script, the $commandDN variable specifies the distinguished name (DN) of the Custom Command. For information on how to get the DN of a directory object, see http://adaxes.com/sdk/?HowDoI.GetDnOfObject.html.
For details, have a look at the following SDK article: http://adaxes.com/sdk/?IAdmCustomCommandAction2.html.