We present a novel, fast and easy measurement technique to measure the beam propagation factor M2 of laser beams using a spatial light modulator (SLM). Two different measurement procedures are outlined, that are both based on digitally simulating the free space propagation of the beam. Hence, the traditional scan in propagation direction can be avoided and no moving components are required. In the first approach the SLM is employed as variable focus lens, yielding differently focused beams in a fixed plane, in which the beam diameter is determined with a static CCD camera. Using standard Gaussian optics the measured data can be fitted with the theoretical curve yielding the M2 value as a fit parameter. The second approach is based on the principles of the angular spectrum method, after which the propagated (near) field is obtained after multiplication with a transfer function of free space in the far field and back transformation to the near field. In the experiment the angular spectrum method is easily implemented by transforming the field under test with a simple lens onto the SLM, displaying the mentioned transfer function on the SLM, and transforming back to a fixed plane, in which the changing beam diameter is recorded with a CCD camera. To prove both techniques, reference beams of Laguerre-Gaussian type with known M2 value were generated and the beam propagation ratio measured. The comparison with the theoretical predictions reveals excellent agreement and emphasizes the fidelity of the M2 measurement.