The PowerShell script provided on the Deployment Pool/Deployment Group Forms in Azure DevOps is very useful, but does not show all the command line switches to allow you to fully automated scripted deployment of Azure DevOps Agents
I find the following two snippets cover most bases
Register as part of a Deployment Group with tags
.\config.cmd --deploymentgroup --deploymentGroupName '{your-deployment-group}' `
--agent $env:COMPUTERNAME `
--runasservice `
--windowsLogonAccount "NT AUTHORITY\SYSTEM" `
--work '_work' `
--url '{your-organisation-url}' `
--auth pat --token {your-token} `
--projectname '{your-project}' `
--addDeploymentGroupTags --deploymentGroupTags "{comma-separated-tags}"
Register as part of a Deployment Pool
.\config.cmd --deploymentpool --deploymentPoolName '{your-deployment-pool}' `
--agent $env:COMPUTERNAME `
--runasservice `
--windowsLogonAccount "NT AUTHORITY\SYSTEM" `
--work '_work' `
--url '{your-organisation-url}' `
--auth pat --token {your-token}
NB
If you are using the provided script, simply replace the contents of .\config.cmd ... ;
You can see all the possible switches using
.\config.cmd --help