re-write AD and Broker scripts