ยง 6311. Preliminary injunction. 1. A preliminary injunction may be granted only upon notice to the defendant. Notice of the motion may be served with the summons or at any time thereafter and prior to judgment. A preliminary injunction to restrain a public officer, board or municipal corporation of the state from performing a statutory duty may be granted only by the supreme court at a term in the department in which the officer or board is located or in which the duty is required to be performed. 2. Notice of motion for a preliminary injunction to restrain state officers or boards of state officers under the provisions of this section must be upon notice served upon the defendant or respondent, state officers or board of state officers and must be served upon the attorney general by delivery of such notice to an assistant attorney general at an office of the attorney general in the county in which venue of the action is designated or if there is no office of the attorney general in such county, at the office of the attorney general nearest such county.