Creating Events in Powershell

53 Views Asked by At

The Task:

I'm writing a script that makes changes to an AD Object (user account) in sequential order:

  1. Name change
  2. Group add
  3. Demographics change
  4. Manager name added
  5. Add email address

The problem:

I want a way to notify the next process in the sequence to start after confirming that the previous process has taken place. The best solution I've been able to write is a loop that constantly checks for a "version" count increment on the DC where I'm making the change. What I'd prefer to do is make a change to an object's attribute, have the version count increment trigger a "change" event that I subscribe to which would then trigger the next function\task in the sequence to begin.

I've tried searching the net for all sorts of ways to "watch" for a property change on an object, but I can't seem to find how to do that. Anyone have any good starting points? or Suggestions on how I can use events in combination with property changes on PowerShell objects that do not have an event class member? This is not for a GUI. Just a basic script.

0

There are 0 best solutions below