(a) The court, on its own motion or on application of a party, may issue an appropriate order directing, restraining, or otherwise controlling the conduct of a person who is properly before the court, if the court finds that the conduct:
(1) Is or may be detrimental or harmful to a child over whom the court has jurisdiction;
(2) Will tend to defeat the execution of an order or disposition made or to be made under this subtitle; or
(3) Will assist in the rehabilitation of or is necessary for the welfare of the child.
(b) Subsection (a) of this section shall apply to a person not a party to the petition if the person is given:
(1) Notice of the proposed order controlling the person’s conduct; and
(2) The opportunity to contest the entry of the proposed order.
(c) An order issued under this section is enforceable under Title 15, Chapter 200 of the Maryland Rules.