Passing parameters to custom command in scheduled task
Dear support,
I'm trying to automate network share creations via custom commands.
They idea is to create share and groups with command A and schedule execution of Command B (assigning permissions) after AD sync to other site (in 3h).


I've succedded so far to create a scheduled task, with a custom command action and domain scope, but I'm strugling how to schedule Command B with necessary arguments (server and folder names). Can you please advise? 
Here's my code so far



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

$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"

$admService = $admNS.GetServiceDirectly("localhost")

# Bind to the 'File server tasks' container

$scheduledTasksPath = $admService.Backend.GetConfigurationContainerPath("ScheduledTasks")

$scheduledTasksPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" $scheduledTasksPath

$myContainerPath = $scheduledTasksPathObj.CreateChildPath("CN=File server tasks")

$myContainer = $admService.OpenObject($myContainerPath,$NULL, $NULL, 0)

# Create a Scheduled Task

$task = $myContainer.Create("adm-ScheduledTask", "CN=File server tasks")

$task.ObjectType = "Domain"

$task.Description = "Assign NTFS permissions and share %param-folder%"

$task.Disabled = $False

$task.ExecutionMoment = "ADM_BUSINESSRULEEXECMOMENT_BEFORE"

$task.OperationType = "none"

$recurrencePattern = $task.GetRecurrencePattern()

$recurrencePattern.RecurrenceType = "ADM_RECURRENCEPATTERNTYPE_ONCE"

$recurrencePattern.PatternStartDateTime = (Get-Date).AddHours(3)

$task.SetRecurrencePattern($recurrencePattern)

$task.SetInfo()

# Define actions and conditions for the task

$commandID = "{e944e4df-6081-4b9d-8640-52eede7d3615}"

$actionsAndConditions = $task.ConditionedActions.Create()

$actionsAndConditions.ConditionsLogicalOperation = "ADM_LOGICALOPERATION_AND"

$actionsAndConditions.SetInfo()

$action = $actionsAndConditions.Actions.CreateEx("adm-CustomCommandAction")

$action.ExecutionOptions = "ADM_ACTIONEXECUTIONOPTIONS_SYNC"

$removeAction = $action.GetAction()

$removeAction.CustomCommandId = $commandID

$action.SetAction($removeAction)

$action.SetInfo()

$actionsAndConditions.Actions.Add($action)

$task.ConditionedActions.Add($actionsAndConditions)

# Define the scope for the task

$scopeItem = $task.ActivityScopeItems.Create()

$scopeItem.BaseObject = $Context.TargetObject

$scopeItem.Type = "ADM_SCOPEBASEOBJECTTYPE_CONTAINER"

$scopeItem.Inheritance = "ADS_SCOPE_BASE"

$scopeItem.Exclude = $False

$scopeItem.SetInfo()

$task.ActivityScopeItems.Add($scopeItem)
```
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>.
A couple of notes to get started:



> 
> .apply(literal\_eval)
> 
> 
> 


Wouldn't this be better as `map`?



> 
> I then re-create the Dask DF:
> 
> 
> ddf = dd.from\_pandas(ddf\_out, npartitions=nCores)
> 
> 
> 


`ddf_out` was already a dask dataframe, I don't know why you had to do this.



> 
> The columns in result seem to match those in metadir.
> 
> 
> 


The value of `result.columns` is taken from the meta you provided, no computing happens until you ask for it (dask is lazy in most operations). Does the ValueError exception not provide further information?


Here is a full example



```
x = ({'F9_07_PZ_COMP_DIRECT': '0',
  'F9_07_PZ_DIRTRSTKEY_NAME': 'DEBRA MEALY',
  'F9_07_PZ_COMP_OTHER': '0',
  'F9_07_PZ_COMP_RELATED': '0',
  'F9_07_PZ_TITLE': 'CHAIR PERSON',
  'F9_07_PZ_AVE_HOURS_WEEK': '1.00',
  'F9_07_PC_TRUSTEE_INDIVIDUAL': 'X'},
 {'F9_07_PZ_COMP_DIRECT': '0',
  'F9_07_PZ_DIRTRSTKEY_NAME': 'HELEN GORDON',
  'F9_07_PZ_COMP_OTHER': '0',
  'F9_07_PZ_COMP_RELATED': '0',
  'F9_07_PZ_TITLE': 'VICE CHAIR',
  'F9_07_PZ_AVE_HOURS_WEEK': '1.00',
  'F9_07_PC_TRUSTEE_INDIVIDUAL': 'X'})
df = pd.DataFrame({'a': x})
d = dd.from_pandas(df, 1)
meta = pd.DataFrame(columns=['F9_07_PZ_COMP_DIRECT', 
       'F9_07_PZ_DIRTRSTKEY_NAME',
       'F9_07_PZ_COMP_OTHER', 'F9_07_PZ_COMP_RELATED', 'F9_07_PZ_TITLE',
       'F9_07_PZ_AVE_HOURS_WEEK', 'F9_07_PC_TRUSTEE_INDIVIDUAL'], dtype="O")
d.map_partitions(lambda df: df.a.apply(pd.Series), meta=meta).compute()

```

How did I know what `meta` to use? I applied the function to the pandas dataframe - you might use a small piece of the dataframe to do this.


Some additional notes:


* it is an anti-pattern to load the data with pandas, pass to dask workers and then gather the whole result back to a pandas (in memory) dataframe, you are very unlikely to see a speedup this way and may incur a lot of overhead. You are better off loading with something like `dd.read_csv`, and aggregating or writing with dask functions too. Only `compute()` on something that will be small or not return anything (because it involves writing the output). The official examples do not use from\_pandas.
* string and dict processing are python methods, and so hold the interpreter lock (GIL) of any python function: threads will not actually run in parallel. To get parallelism, you need to run in processes, which is most easily achieved using <https://docs.dask.org/en/latest/setup/single-distributed.html>
* the distributed scheduler also gives you access to the dashboard, which has a lot of useful information to diagnose how your system is running. You can also configure a lot about its behaviour, in case you have firewall rules you need to obey. def render("show.json", %{user: user} = assigns) do

%{

data: render\_one(user, admin.userview, "user.json", assigns)

}

end

there’s no “implicit” assigns map, which all functions would automatically inherit somehow. you need to explicitly pass the assigns map onwards into rend… Dapper just wraps raw ADO.NET; raw ADO.NET doesn't offer a facility for this, therefore dapper does not. What you want is `SqlBulkCopy`. You could *also* use a table-valued-parameter, but this really feels like a `SqlBulkCopy` job.


In a pinch, you can *use* dapper here - `Execute` will unroll an `IEnumerable<T>` into a series of commands about `T` - but it will be lots of commands; and unless you explicitly enable async-pipelining, it will suffer from latency per-command (the pipelined mode avoids this, but it will still be n commands). But `SqlBulkCopy` will be *much* more efficient.


If the input data is an `IEnumerable<T>`, you might want to use `ObjectReader` from FastMember; for example:



```
IEnumerable<SomeType> data = ...
using(var bcp = new SqlBulkCopy(connection))
using(var reader = ObjectReader.Create(data, "Id", "Name", "Description"))
{
    bcp.DestinationTableName = "SomeTable";
    bcp.WriteToServer(reader);
}

``` There is an MS DOS tool you can use to add a service. It is SC.EXE. I shall illustrate its use with an example.

Suppose, that I had installed two Coldfusion 11 instances named *testInstance1* and *myNewCFInstance*. Their installation directories are, respectively

C:\ColdFusion11\testInstance1\

C:\ColdFusion11\myNewCFInstance\

To add them as Windows services, you could proceed as follows.

Click on the Windows Start symbol.

When you type *cmd* in the search field, a link to the DOS command prompt should appear.

Right-click on the link and select to *Run as Administrator*. You should now get the DOS command prompt.

You can now run the DOS command, SC, to add a Windows service. You will have to do this for each and every instance you wish to add, one instance at a time.

**testInstance1**

Type the following after the prompt and press enter:

*sc create "ColdFusion 11 testInstance1" binPath= C:\ColdFusion11\testInstance1\bin\coldfusionsvc.exe start= auto DisplayName= "ColdFusion 11 testInstance1"*

Explanation:

* You must leave a single space after each equal (=) sign.
* "ColdFusion 11 testInstance1" is the name of the Windows service.
* The start type is Automatic.

![](/legacyfs/online/1191406_pastedImage_20.png)

You should get the result "SUCCESS".

To add the description, you have to run SC once again:

*sc description "ColdFusion 11 testInstance1" "My first ColdFusion 11 instance"*

Explanation:

* You must use the exact Windows service name. It is, in this case,  "ColdFusion 11 testInstance1".
* You may use any description you like. But I would advise you to use something like "ColdFusion 11 instance name\_of\_instance"

![](/legacyfs/online/1191405_pastedImage_16.png)

**myNewCFInstance**

For my second instance, the DOS commands I used to create the Windows service and to add the description were, respectively,

*sc create "ColdFusion 11 myNewCFInstance" binPath= C:\ColdFusion11\myNewCFInstance\bin\coldfusionsvc.exe start= auto DisplayName= "ColdFusion 11 myNewCFInstance"*

Followed by

*sc description "ColdFusion 11 myNewCFInstance" "ColdFusion 11 instance myNewCFInstance"*

Some references:

<https://coldfusionsolution.wordpress.com/2014/11/12/how-to-create-service-for-coldfusion/>

[http://stackoverflow.com/questions/29702700/sc-exe-how-to-set-up-the-description-for-the-windows-ser...](http://stackoverflow.com/questions/29702700/sc-exe-how-to-set-up-the-description-for-the-windows-service)

<https://forums.adobe.com/thread/1152396> 

Should you make a mistake, and wish to delete a service, then see

[How to Delete a Windows Service in Windows 7, 8, 10, Vista, or XP](https://www.howtogeek.com/howto/windows-vista/how-to-delete-a-windows-service-in-vista-or-xp/ "https://www.howtogeek.com/howto/windows-vista/how-to-delete-a-windows-service-in-vista-or-xp/") hi

we can do that by defining a string variable in the very beginning of the process with assign activity or by defining that in variable panel in the studio at the bottom the window

but make sure that we are not assigning any value to that variable later across the workflow

if we assign later th… 1) form controls use a list box for the names of the conference rooms;use datetimepicker for scheduling the reservation...set the format property to custom;set the customformat property to mm dd yyyy hh mm ssof course, will also need ok button2) dataset up the data file like this:room date time1st floor, 6/8/21, 14:00:002nd floor, 6/9/21, 10:00:003rd floor, 6/8/21, 13:30:00reads these records from the file to determine if there is a conflict.if the room is available at the requested time, writes the reservation tothe file (in append mode) and displays a message box saying the reservationis complete. otherwise display a message box saying the room is unavailableat that time. hi phil 
congratulations on creating this. we’re about to upgrade our asana account so will be candidates for this. 
one function that would be super useful to us would be to have the subtasks of a task populate based on a selection made in a custom field. e.g. if we change content type to blog post… We need the whole code to answer to your question. [submit your assignment](https://www.assignmentexpert.com/submit) to our control panel and our experts will help you. hi james,

as you already figured out, custom transactions does not support automatic instrumentations (xhr, fetch, resources) which means the user would have to start span and attach it to the transaction manually.

and yes by setting { managed: true } in the starttransaction option the transaction… Please see: [How do I schedule a task to update indexes?](https://qa.mythicsoft.com/14733/how-do-i-schedule-a-task-to-update-indexes?show=14733#q14733)