give parameters from a script to workflow as global parameters

hi

i have a CSV file with a title line (company,sn,givenname,department,position,telephone.. and the users from line 2 on.

now i want to add these parameters mentioned above as workflow parameters to use when i do a for each.

i put the parameters as following:


$files = Get-ChildItem C:\incoming\OT_Benutzeranlage | where { ! $_.PSIsContainer }

foreach($file in $files){
$user = Import-Csv $file.FullName -Encoding default -Delimiter ";"
$workflow.parameter("Company") = $user.Firma
$workflow.parameter("name") = $user.Vorname
$workflow.parameter("sn") = $user.Nachname
$workflow.parameter("phone") = $user.Telefon
$workflow.parameter("department") = $user.Abteilung
$workflow.parameter("position") = $user.Position


echo $workflow.parameter("department") >> C:\temp\xxx.txt

}

but all parameters are empty. any clou how to bring them in, that the user creation step will work.

thanks for help.


Pablo

Parents
  • Hi  

    What are you actually trying to do? What is the follow on action based you're trying to accomplish, as in essence all you would be doing here is looping through a series of files attempting to set a property, which if you were able to write to them would ultimately only hold the last value you set (unless you're adding each entry into a different value in a position in an array), from all the files.

    I'm double checking, but I also believe these workflow property are usually set at the Workflow level (manually), and the values set again the workflow are then retrieved, IE:

    • $computers = $Workflow.ParameterEx("Computers")
    • $logonName = $Workflow.Parameter("LogonName")

    If you're trying to use the CSV files to update the users, it might be easier to just use the Active Roles Sync Service component. But if you can explain what you're trying to do with the information, we might be able to give you an alternative method.

    Cheers

    Stu

  • Hello Stu

    My problem is, that i have a user creation process behind with approval.. so with the sync the approval is ignored.. that's why i want to fill the parameters to use in the process step behind

  • So in essence what your trying to do is bulk create users, but require approval before the object actually gets created? But Sync Services doesn't give you the option to require approval. And if you try enforcing the approval you get an error 

    If that's the case, I would just use two separate workflows

    1) Change Workflow - For the approval (which is triggered on creation of a new user account in whichever OU's your script will create the objects), which would just have a single workflow activity step (the approval rule). Ensuring that "Enforce approvals" option is enabled, so any one, including the Administration Service.

    2) Automation Workflow - Which executes a script, which reads in all the users from CSV, then for each object uses Create-QADUser commandlet (with the proxy flag) to create the objects.

    When you then run the Automation Workflow (either as a scheduled process, or on Demand) you'd see soemthing like this (In this example, the script I'm running to create the "Users" is called "Blah")

    Within the Web Sites approval section, I see this:

    Before approval within my target (parent) OU I see

    After I approve it, I see

    My script is nothing special, I'm only creating a single user, however you've already got the code to loop through all the files you need, and you could put paramters into your script, to be provided by the Automation Workflow of the files you want to rule, or the directory with the files you want to read in..

    Hope this helps

    Stu

  • Thanks Stu

    Will try it.. could help in my case

Reply Children
No Data