none
Create user based If exist or not

    Question

  • Hi everybody,

    I would like if anyone can help me

    I have a Runbook that create a username based at name provided, example:

    Initialize Data: ROBSON DE CARVALHO JOAQUIM

    This moment is generated two names with PowerShell and sent the two results for the next activity:

    ROBSON.JOAQUIM

    ROBSON.CARVALHO

    The next step will execute a runbook to check if the user exists in AD, if not, the next activity is to create the user.

    ! The problem, as the second line will be the next activity and if the User does not exist too, the next activity will be to create another user.

    I would like that if the user does not exist in the first activity the next activity creates the User and the next stop activities.

    If the User's first activity exisitr it tries the next and if there creates the User and otherwise sends an email.

    Flow

    Flow FIND USER

    


    Robson Hasselhoff - Follow me @Robk9e


    Thursday, October 24, 2013 5:58 PM

Answers

  • Hi Stefan and PIfM,

    Done differently in the runbook FIND_USER created a powershell that does the checking and return just a user for create or not.

    And All work now... Stefan I will see your solution, many thanks again!


    Robson Hasselhoff - Follow me @Robk9e

    Tuesday, November 05, 2013 5:47 PM

All replies

  • Hi,

    you must place the Activities in the two Runbook like this:

    • One that calculates the UserName AND check if the user exist.
    • The other that Invokes the first Runbook until a new UserName is found OR the max number of attempts (Common Published Data) is greater or equal 2.

      Check user exists

    Regards,

    Stefan


    www.sc-orchestrator.eu , Blog sc-orchestrator.eu

    Friday, October 25, 2013 8:02 AM
  • Hi !

    I would do it this way :

    First activities don't change.

    Then :

    "SEPARATE" is used to declare two variables in Powershell or C# as you like :

    $Name1 = ValueFromPreviousActivities

    $Name2 = ValueFromPreviousActivities

    Declare these variables as Published Data.

    "FIND_USER" will search for "Name1".

    If it doesn't exist, it will be created with activity "Create User".

    If it exists, it will run activity "FIND_USER2" which will search for "Name2".

    If "Name2" exists, it will send an email, otherwise, "Name2" will be created.

    I hope this will help.

    Friday, October 25, 2013 8:03 AM
  • Hi !

    I would do it this way :

    First activities don't change.

    Then :

    "SEPARATE" is used to declare two variables in Powershell or C# as you like :

    $Name1 = ValueFromPreviousActivities

    $Name2 = ValueFromPreviousActivities

    Declare these variables as Published Data.

    "FIND_USER" will search for "Name1".

    If it doesn't exist, it will be created with activity "Create User".

    If it exists, it will run activity "FIND_USER2" which will search for "Name2".

    If "Name2" exists, it will send an email, otherwise, "Name2" will be created.

    I hope this will help.

    Sophie,

    Thanks for the reply.

    But I can not declare variables fixed because the name is dynamic, example:

    TOM CRUISE JOLIE SILVA CARLSON

    The result of the script suggestion is:

    tom.silva
    tom.jolie
    tom.cruise

    tom.carlson

    And based on that research is done and verify if the User exists or not.

    At the moment there is no user, the runbook is creating the 3 users and this is the initial problem that I am not able to solve. 

    I need If a user is created, subsequent tasks stop running immediately.


    Robson Hasselhoff - Follow me @Robk9e

    Friday, October 25, 2013 5:36 PM
  • Hi,

    you must place the Activities in the two Runbook like this:

    • One that calculates the UserName AND check if the user exist.
    • The other that Invokes the first Runbook until a new UserName is found OR the max number of attempts (Common Published Data) is greater or equal 2.

      Check user exists

    Regards,

    Stefan


    www.sc-orchestrator.eu , Blog sc-orchestrator.eu

    Hi Sefan, many thanks for the reply,

    I try your suggestion but did not work.

    The RUNBOOK 1 has the flow below

    Initialize Data: TOM CRUISE JOLIE SILVA CARLSON

    Result Activity EXPAND in the image

    When arrive on RUNBOOK FIND_USER it verify if user exists or no. 

    If exists it return with value of continue =1 if not exists it return with value continue 0

    On loop if value = 0 loop stop and create the user, but like all names returns 0 it will create 4 users and loop not stop.

    Thanks advance dear!


    Robson Hasselhoff - Follow me @Robk9e

    Friday, October 25, 2013 6:02 PM
  • Hi,

    you must check the "wait for completion" in the "Invoke Runbook" Activity ("FIND_USER").

    Regards,

    Stefan


    www.sc-orchestrator.eu , Blog sc-orchestrator.eu

    Sunday, October 27, 2013 7:08 PM
  • Hi Stefan,

    Already cheked, but nothing yet.

    Am I doing something wrong in the configuration?

    Best regards


    Robson Hasselhoff - Follow me @Robk9e

    Sunday, October 27, 2013 11:03 PM
  • Hi,

    nothing wrong do see here, can you export the Workflow and provide it on skydrive?

    Regards,

    Stefan


    www.sc-orchestrator.eu , Blog sc-orchestrator.eu

    Monday, October 28, 2013 12:11 PM
  • Of course dear,

    http://sdrv.ms/1atFo6W

    Many thanks


    Robson Hasselhoff - Follow me @Robk9e

    Monday, October 28, 2013 12:48 PM
  • Hello Robson de Carvalho,

    the bad news is: There is no way to really break out of a "for each multi-valued data value loop"
    (I presume that your "EXPAND" activity produces multi-valued published data?).
    The good news is: There are workarounds.

    One could be:

    If you can make sure that only one instance of your runbook runs at a time you could use a counter:
    First step in your main runbook would be to set the counter to say 0 via the "Modify Counter" activity.

    Before your "Create User" activity (directly behind the invocation of "Find User") you insert
    a "Modify Counter" activity that increments the counters value by e.g. 1.
    Configure the link to the "Create User" activity that it gets only triggered when the counter value (published data from "Modify Counter") equals 1.

    This way the whole "loop" will be executed but only one user will be created.

    There is of cause a lot of overhead and it only works if you do NOT need to run several of these runbooks at once.


    Regards,
    PIfM

    Monday, November 04, 2013 6:16 PM
  • Hi,

    sorry, for the late reply. Here my version: http://sdrv.ms/17ChCJq

    Regards,

    Stefan


    www.sc-orchestrator.eu , Blog sc-orchestrator.eu

    Monday, November 04, 2013 9:22 PM
  • Hi Stefan and PIfM,

    Done differently in the runbook FIND_USER created a powershell that does the checking and return just a user for create or not.

    And All work now... Stefan I will see your solution, many thanks again!


    Robson Hasselhoff - Follow me @Robk9e

    Tuesday, November 05, 2013 5:47 PM