This article provides a comprehensive review of advanced control strategies for power electronics in microgrid applications, focusing on hierarchical control, droop control, model predictive control (MPC), adaptive control, and artificial intelligence. This article provides a comprehensive review of advanced control strategies for power electronics in microgrid applications, focusing on hierarchical control, droop control, model predictive control (MPC), adaptive control, and artificial intelligence. Grid-forming, particularly those utilizing droop control and virtual synchronous generators (VSG), can actively regulate the frequency and voltage of microgrid systems, exhibiting dynamic characteristics akin to those of synchronous generators. Although droop control and VSG control each have. Although droop control and VSG control each have distinct benefits, neither can fully meet the diverse, dynamic needs of both grid-connected (GC) and islanded (IS) modes. Additionally, the coupling between active and reactive power can negatively impact microgrids' dynamic performance and. In this paper, an algorithm is presented to control an inverter and make it complete and versatile to work in grid-connected and in isolated modes, injecting or receiving power from the grid and always compensating the harmonics generated by the loads in the microgrid.