When a defendant against whom an action has commenced for any of the causes specified in subdivision (1) of section 1172 of this title, is determined to be guilty of usurping or intruding into, or unlawfully holding or exercising any office or franchise, judgment shall be given that such defendant be excluded therefrom. The court may also in its discretion impose a fine upon the defendant not exceeding $500.