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 is the name of the domain)

Get-SCOMAgent -DNSHostName *DC* | Disable-SCOMAgentProxy

$credential = (Get-Credential)

Get-SCOMAgent -DNSHostName *DC* | 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!