The vast majority of large telescopes are now equipped with Adaptive Optics (AO) systems, and many use lasers to create artificial stars (laser guide stars, LGS). Despite the significant advances in the use of LGS for AO, some problems persist during the operations. In particular, achieving a satisfactory performance in terms of on-sky laser power and beam quality usually requires frequent and complex alignments of the laser system, beam transfer optics and launch telescope. To provide easier calibrations and faster pre-setting of the LGS facility during routine operations, we propose the introduction of active elements (deformable mirrors) in the laser beam before it is propagated to the sky. The paper studies an AO configuration with two deformable mirrors to correct for quasi-static and dynamic aberrations. The problem of determining the correction phases to apply to the deformable mirrors is particularly challenging due to the highly nonlinear problem and the possible appearance of branch points. We propose an iterative method based on a phase retrieval algorithm that uses a weighted least squares unwrapper to avoid branch points. Simulations are performed aiming to a future implementation in the Gemini Multi-conjugate-adaptive-optics System (GeMS). Results show that the technique is accurate and robust, with a reasonable convergence speed.