0 votes

Hi,

I followed this example: https://www.adaxes.com/sdk/IAdmTop6.html, but because the Custom Command is disabled, I get the following error message:

System.Management.Automation.MethodInvocationException:
Exception calling "ExecuteCustomCommand" with "2" argument(s): "Custom command '<the name of the custom command>' is disabled." 
---> System.InvalidOperationException: Custom command '<the name of the custom command>' is disabled. 
at Softerra.Adaxes.Adsi.AdmObjectPipelined.ExecuteCustomCommand(String customCommandIdArg, IAdmCustomCommandArguments argumentsArg) 
at CallSite.Target(Closure , CallSite , Object , Object , Object ) 
--- End of inner exception stack trace --- 
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) 
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame) 
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) 
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)

The Custom Command should not be available directly through the context menu, since it is meant to only be execuded by a script, another custom command, or some other form of automation.

For clarity, It works if I enable the Custom Command.

I am using Adaxes 2018.2

Best Regards Martin

by (150 points)

1 Answer

0 votes
by (288k points)
selected by
Best answer

Hello Martin,

Unfortunately, it is not possible. Disabled Custom Commands can only be executed in Business Rules, Scheduled Tasks and other Custom Commands. As a solution, you can first enable the command in your script and then disable it after execution as in the below example.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to the Custom Command
$commandDN = "CN=My Command,CN=Custom Commands,CN=Configuration Objects,"+
    "CN=Adaxes Configuration,CN=Adaxes"
$command = $admService.OpenObject("Adaxes://$commandDN", $NULL, $NULL, 0)

# Enable Custom Command
$command.Disabled = $False
$command.SetInfo()

# Specify arguments for command execution
$commandArguments = $command.CreateArguments()
$commandArguments.SetParameterValue("MyParameter", "MyValue")

# Bind to the Organizational Unit
$containerDN = "OU=My OU,DC=domain,DC=com"
$container = $admService.OpenObject("Adaxes://$containerDN", $NULL, $NULL, 0)

# Execute the Custom Command for all users in the Organizational Unit
$container.Filter = @("user")

foreach ($user in $container)
{
    $user.ExecuteCustomCommand($command.CommandID, $commandArguments)
}

# Disable Custom Command
$command.Disabled = $True
$command.SetInfo()
0

Hi,

Thank you for the quick reply, this solves my problem.

Related questions

0 votes
1 answer

I'd like to be able to either send an email report or export a CSV of all of the business rules carried out when a user is disabled. This would be ... Management Activity section but this includes things that weren't part of the disable operation. Thanks

asked Feb 19, 2020 by bavery (250 points)
0 votes
1 answer

Is it possible to call execution of Adaxes custom command via SPML?

asked Oct 16, 2019 by Dmytro.Rudyi (920 points)
0 votes
1 answer

For creating a computer object, we want to check if the entered CN is already used in our AD. And for that we want to use a powershell script. An other dot ... powershell script should be start before creating the computer object, right? Thanks for your help.

asked Jun 4 by KEME (80 points)
0 votes
1 answer

Hi, would it be possible to script a workstation in AD and also directly from our local SCCM environment ?

asked Oct 28 by ddesmedt (40 points)
0 votes
1 answer

I have a dropdown-field on the web surface, which is populated by a script. The script looks up all groups in a specific OU and displays them. In the Property Pattern ... random order. What should i do to show the groups in alphabetical order in the portal?

asked Sep 15, 2020 by lohnag (160 points)
3,541 questions
3,232 answers
8,225 comments
547,800 users