Measurement of defocus using the astigmatic lens approach is a very simple, fast and effective technique. The approach uses an astigmatic lens to incorporate astigmatism into the test beam and the measurement of defocus is done from the intensity measurement at the focal plane of the lens. The present research is on the use of computer generated hologram in the astigmatic lens approach for measuring the strength of defocus present in the test beam. The use of a computer generated hologram in conjunction with a liquid crystal spatial light modulator allows a dynamic change in the strength of astigmatism without disturbing the measurement setup. The strength of astigmatism incorporated by the astigmatic lens on the other hand is a very important parameter that determines the sensitivity, dynamic range and resilience to cross-talk of the technique. Therefore, a dynamic change in the strength of astigmatism is very important to switch to a different mode of operation as per the demand of the applications. This is not possible with an astigmatic lens as any change in the strength of astigmatism can be achieved only by replacing the lens itself, thereby disturbing the whole measurement setup. In this paper, we provide a brief discussion on the principle of an astigmatic defocus sensor followed by the process of its implementation using computer generated hologram. Simulation is carried out to validate the technique. The simulation results are further verified experimentally with the help of a proof of principle laboratory setup. The technique is validated for all three modes of operation, i.e. maximum sensitivity, higher dynamic range and resilience to cross-talk.