This is the code I use to deploy Managed DevOps pools. The primary goal is to support AzDM, but it should be usable for most scenarios with little customizations.
Some things are excluded by choice as I don't see a reason to add support for everything right now.
Use it at your own will - and feel free to ask for changes or improvements.
//Bjompen