distributed generations (DGs) make the microgrid active and more flexible. In addition of power demand supplying, the DGs can be used for improving power quality indices such as reducing voltage unbalance. However, for purposes of power quality improvement the microgrid controllers' coefficients should be adjusted optimally. Due to microgrid components accurate modeling, the controllers’ adjustment is a complex problem that should be solved using an appropriate approach. The purpose of this paper is proposing particle swarm optimization (PSO) algorithm so as to find the optimal coefficients of a PI controller for enhancing voltage unbalance factor (VUF) in a microgrid. The objective function is considered minimization of integral of absolute error index which is solved under technical constraints. The results of simulation indicate the robustness and success of the proposed algorythm.