We use the Wigner distribution to study systems subjected to random forces. We define the instantaneous spectrum as the ensemble average of the Wigner distribution, and we write the differential equation whose solution gives us the time-varying spectrum of the state variable. We consider the cases of both constant and time-varying coefficients. We apply the method to study the instantaneous spectrum of a harmonic oscillator driven by Gaussian noise, with both constant and time-varying coefficients. In the latter case our method clearly reveals the nonstationarity of the power spectrum and we confirm our result by numerical simulations.