Based on the distributed battery energy storage system (BESS), a grid-connection strategy considering harmonic restraint is investigated. It can compensate the harmonic current to the grid by measuring the grid harmonics, then harmonic compensation is implemented to reduce the total harmonic distortion (THD) of the grid current. In this paper, the method of measuring harmonics in the grid and the control principle of providing power supply and harmonic compensation based on BESS are described. On this basis, the control flow is designed. Firstly, the energy storage grid-connected system is built in MATLAB/Simulink and the uncontrolled rectifier with inductive and resistance load is used for testing. The simulation results show that the grid current contains many harmonics, and the grid current THD decreases significantly by controlling BESS for harmonic compensation, which validates that the control method proposed in this paper is accurate and feasible.