There are a lot of power quality problems such as a large number of harmonics and voltage fluctuations, caused by quickly changing diverse types of loads and power resources in microgrid. An optimizing control method based on robust H2/H∞ controllers was proposed by establishing a unified math model of UPQC in micorgrid. The state equation contains the uncertain parameters of the structure, and all allowable uncertainties can meet both the H∞ disturbance attenuation and the optimal H2 performances of the closed-loop control system. The design of robust H2/H∞ controller was transformed into an optimal problem with constraints of linear matrix inequalities, from which the robust H2/H∞ output feedback controllers can be derived. The simulation and experiment results show this method can obtain preferable control effect, fast dynamic response and good robustness.