Run a script when a user is added to a group

Answered Run a script when a user is added to a group

  • Wednesday, December 26, 2012 1:00 PM
     
     

    Do you know how can i success to run a script (PS / Batch), when a user is added to my domain, or a user is added to a group? (When a user is added to a group, i want to run a script)

    Can i do this via group policy or event logs.

    Regards

All Replies

  • Wednesday, December 26, 2012 5:01 PM
     
     

    Thanks for your answer.

    Below sites are also useful for this issue:

    http://www.windowsecurity.com/articles/Attaching-Tasks-Event-Viewer-Logs-Events.html

    http://aymanstechblog.blogspot.com/2012/05/passing-event-details-as-arguments.html

    Regards

    • Marked As Answer by ebasaranoglu Wednesday, December 26, 2012 5:02 PM
    • Unmarked As Answer by ebasaranoglu Wednesday, December 26, 2012 5:02 PM
    •  
  • Friday, December 28, 2012 9:58 PM
     
     

    An other question:

    How is it possible to run one/same script for 5 event id. 

    Creating 5 task is for all event ids is an option. But i want to select 5 event id in the same task. But there is not any option for this:

    http://3.bp.blogspot.com/-JRILB_iMLCE/UNs4qLO8wAI/AAAAAAAAAHw/RriGA1kQHyo/s1600/04.jpg

  • Friday, December 28, 2012 11:49 PM
     
     Answered Has Code

    Hello,

    You are right, there is no option for this.
    What you can do, you can run a script (or program) that will count
    how often you have ran this program.

    What it does, it will increase a variable everytime you run the program.

    When the variable is 4, it will start your script.

    I hope you know what I mean.

    If globalcount = 4 then
    
    shell "c:\myscript.bat"
    globalcount = 0
    
    Else:
    
    globalcount = globalcount + 1
    End
    
    End If
    This script is ony an example.
    You will need to write the current value of globalcount to a registrykey or textfile.


    MVP Group Policy - Mythen, Insiderinfos und Troubleshooting zum Thema GPOs: Let's go, use GPO!



  • Monday, December 31, 2012 11:56 PM
     
     

    Hello,

    That is not what I meant. But it is also useful. 

    I want to create one task for different events. For example, below task is prepared for event id 517:

    http://www.windowsecurity.com/img/upl/image0061278963372709.jpg

    I want to run same script for event ids 632, 630, 660 etc.

  • Tuesday, January 01, 2013 2:17 AM
     
     

    Creating 5 task is for all event ids is an option. But i want to select 5 event id in the same task

    Ok, I understood.

    To make it short, the easiest way is to create five different tasks.



    MVP Group Policy - Mythen, Insiderinfos und Troubleshooting zum Thema GPOs: Let's go, use GPO!

  • Tuesday, January 01, 2013 11:29 AM
     
     Answered

    Another way would be to create one task

    (not a Basic Task) with different triggers:


    MVP Group Policy - Mythen, Insiderinfos und Troubleshooting zum Thema GPOs: Let's go, use GPO!

  • Friday, January 04, 2013 11:12 PM
     
     
    Thanks for your help. That is it