I'm trying to automate the creation and deletion of a folder each time a computer is added or removed from the domain.
When a computer joins a domain, I'd like folder w/ %computername% to be created. When a computer is removed from a domain, I'd like folder %computername% deleted from the domain.
One thing that I'm trying is to create a task in Task Scheduler, that begins the task "On an Event". That way I can check for the event when a computer joins/removes a domain, and then create or delete accordingly. Is there a way for the task to parse the eventlog so I can extract the computer name from it when the task is run?
Or is there a better way of doing this?