For problems governed by a non-normal operator, the leading eigenvalue of the operator is of limited interest and a more relevant measure of the stability is obtained by considering the harmonic forcing causing the largest system response. Various methods for determining this so-called optimal forcing exist, but they all suffer from great computational expense and are hence not practical for large-scale problems. In the present paper a new method is presented, which is applicable to problems of arbitrary size. The method does not rely on timestepping, but on the solution of linear systems, in which the inverse Laplacian acts as a preconditioner. By formulating the search for the optimal forcing as an eigenvalue problem based on the resolvent operator, repeated system solves amount to power iterations, in which the dominant eigenvalue is seen to correspond to the energy amplification in a system for a given frequency, and the eigenfunction to the corresponding forcing function. Implementation of the method requires only minor modifications of an existing timestepping code, and is applicable to any partial differential equation containing the Laplacian, such as the Navier-Stokes equations. We discuss the method, first, in the context of the linear Ginzburg-Landau equation and then, the two-dimensional lid-driven cavity flow governed by the Navier-Stokes equations. Most importantly, we demonstrate that for the lid-driven cavity, the optimal forcing can be computed using a factor of up to 500 times fewer operator evaluations than the standard method based on exponential timestepping.