The following is a quick PowerShell script which uninstalls agents based upon matching a naming convention. This example identifies a unique naming for the servers such as those which are named with “DC” indicating they are a domain controller: (where xyz.com is the name of the domain)

Get-SCOMAgent -DNSHostName *DC*.xyz.com | Disable-SCOMAgentProxy

$credential = (Get-Credential)

Get-SCOMAgent -DNSHostName *DC*.xyz.com | foreach{Uninstall-SCOMAgent -Agent $_ -ActionAccount $credential}

##Note: Initially this was attempted without using the foreach but the results were unreliable.

Thank you to Ambers Ferrara for his example of this above!