Better ways of automatinginstall of Azure Pipelines Agents on on-prem Windows machines?

Does anyone have a suggestion for smart ways to automate the install of Azure Pipelines Agents on on-prem Windows machines? I’m thinking of building a pipeline to kick off a pipeline that will install it via WinRm. I’ve googled a bit, but I’m having a a hard time finding a good article. Any suggestions appreciated. Thanks!

Are the machines in a domain, then you can use Group Policy.
If its VMs in cloud, you have extensions that run scripts.
If its VMS where you own the onprem hosts, you can run powershell scripts on their boot.
If its barebone servers, if you control the windows VM image you can create your own image with everything needed, sysprep it and then use it when you deploy new hardware.

Remember that by default WinRM is not open. However vms in azure based on their default image does come with WinRM (http only) open

Thanks that is very helpful.

Arie nailed it. Are they freshly deployed VMs or existing machines? New VM it depends on how the template is prepped/deployed and its kind of old school but if it’s first boot after oobe on a sysprep’d you can use a setupcomplete.bat to call a script too. I’ve used that for all sorts of automation deploying OSs.

Existing machines I’ve done the pipeline method using remote PS tasks too. You can script out 1 agent or as many as you want depending on your plans.

Worth a look too if you can get chocolaty on the servers and can reach the feed https://community.chocolatey.org/packages/azure-pipelines-agent|https://community.chocolatey.org/packages/azure-pipelines-agent