In recent years, the harmonics and unbalance problem endanger the voltage and current quality of power systems due to increasing usage of nonlinear and unbalance loads. Using DG interfacing inverters is proposed for voltage or current compensation. In this paper, a flexible control method is proposed to compensate voltage and current unbalance and harmonics using the Distributed Generation (DG) interfacing inverters. This method is applicable to both grid-connected and islanded microgrids. In the proposed method, not only the proper control of active and reactive powers can be achieved, but also there is the flexibility in compensating the voltage or current quality problems at DGs terminal or Point of Common Coupling (PCC). This control strategy consists of active and reactive powers controllers and voltage/current quality improvement block. The controller is designed in stationary (αβ) frame. An extensive simulation study has been performed and the results demonstrate the effectiveness of the proposed control scheme. The results show that depending on the compensation mode, the harmonics and unbalance compensation of DGs’ output current, MG’s injected current to the grid as well as PCC and DG voltages can be achieved in grid-connected operation of MG while in the islanded operation, the PCC and DG voltages compensation can be obtained by using the proposed control scheme.