The properties of ferroelectric devices are strongly influenced, besides crystallographic features, by defects in the material. To study this effect, a fully coupled electromechanical phase-field model for 2D ferroelectric volume elements has been developed and implemented in a Finite Element code. Different kinds of defects were considered: holes, point charges and polarization pinning in single crystals, as well as grain boundaries in polycrystals, without and with additional dielectric interphase. The impact of the various types of defects on the domain configuration and the overall coercive field strength is discussed in detail. It can be seen that defects lead to nucleation of new domains. Compared to the energy barrier for switching in an ideal single crystal, the overall coercive field strength is significantly reduced towards realistic values as they are found in ferroelectric devices. Also the simulated hysteresis loops show a more realistic shape in the presence of defects.