The Brownian motion (BM) of particles in a fluid under the influence of a moving harmonic potential is described analytically. It is assumed that the bath is viscous and particles constituting it experience Stokes' force with friction coefficients that can depend on time. The generalized Langevin equation (GLE) is derived from the equations of motion for the bath and Brownian particles. It has a familiar form, but its memory kernel generalizes the expressions known from the literature even in the case of constant friction. Analytical solutions of the found GLE are obtained for the mean and mean squared displacements of the Brownian particle, assuming the overdamped character of its motion and both the overdamped and underdamped dynamics of bath particles. In the case of constant friction, the model well describes the BM when the external potential does not move so that the system is in equilibrium. The results determined by the time-dependent friction of the bath particles must be specified for concrete fluids. An example of Lennard–Jones atomic liquid is considered with the recently proposed exponential time dependence of the friction coefficient.