With the increasing reliance on microgrids as flexible and sustainable solutions for energy distribution, securing decentralized electricity grids requires robust cybersecurity strategies tailored to microgrid-specific vulnerabilities. The research paper focuses on enhancing detection capabilities and response times in the face of coordinated cyber threats in microgrid systems by implementing advanced technologies, thereby supporting decentralized operations while maintaining robust system performance in the presence of attacks. It utilizes advanced power engineering techniques to strengthen cybersecurity in modern power grids. A real-world CPS testbed was utilized to simulate the smart grid environment and analyze the impact of cyberattacks in real-time. Several types of cyberattacks were implemented, including a denial-of-service (DoS) attack, a Telnet attack on port 23, and attacks on the Modbus protocol via port 502. The results showed that the system lost complete communication with the Supervisory Control and Data Acquisition (SCADA) components after the attack, resulting in significant power surges and distortions in meter readings. The study provides a practical assessment of how smart infrastructure is affected by targeted attacks, emphasizing the importance of continuous monitoring and strengthening of sensitive protocols.