We present a dynamical approach to generate defect-free continuous-random-network (CRN) models of hydrogenated amorphous silicon (a-Si:H). Using the atomic co-ordination number of silicon as a collective variable and few configurational constraints, we have shown that classical metadynamics can be used to construct CRN models of a-Si with arbitrary concentrations of dangling-bond co-ordination defects. These defective networks have been subsequently hydrogenated to produce high-quality models of a-Si:H using ab initio total-energy calculations to generate hydrogen (H) microstructures for H concentrations from 7 to 22 at. %. The structural, electronic, optical, and vibrational properties of the models are examined, and the microstructure of the hydrogen distribution is analyzed and compared with experimental data from neutron scattering, spectroscopic ellipsometry, infrared spectroscopy, and nuclear magnetic resonance studies. The results obtained from the models are found to be in excellent agreement with the experimental data.