This paper presents a two-level hierarchical control approach for voltage source inverters used to interface Distributed Generators (DGs) in microgrid applications. The control structure comprises primary and secondary levels. The primary level is a local controller, which consists of voltage and current inner control loops in order to fix the filter capacitor voltage and a virtual impedance loop mainly for voltage harmonics and unbalance compensation. The virtual impedance is set by the central secondary controller to mitigate the voltage distortion at sensitive load bus (SLB). Secondary controller is connected to a measurement unit to obtain the data of voltage harmonics and unbalance at microgrid SLB and broadcasts the commands for adjusting the virtual impedance of each unit. A general case with a combined voltage harmonic and unbalance distortion is considered. In such a case, voltage distortion is mitigated by selective insertion of capacitive virtual impedances for negative sequence of fundamental component as well as positive and negative sequences of main harmonics. The values of virtual capacitances are determined based on the required voltage quality at the load bus; thus, this scheme is titled as adaptive virtual impedance. Experimental results are presented to demonstrate the effectiveness of the proposed control approach.