$aecgroups = get-adgroup -filter * -server "aec01a-dc02.aecuk.aec.local" | ?{($_.distinguishedname -notmatch "CN=Users,DC=aecuk,dc=aec,dc=local") -and ($_.distinguishedname -notmatch "CN=Builtin,DC=aecuk,DC=aec,DC=local")}

foreach($group in $aecgroups){

	$aec = (Get-Adgroupmember $group).count
	$group = $group -replace '^CN=([^,]+).+$','$1'
	try{get-adgroup $group -server "bhm1dc01.controlsdata.com" | Out-null
		$cds = (Get-Adgroupmember $group -server "bhm1dc01.controlsdata.com").count
		
		if($aec.count -ne $cds.count){
			write-host "$($group) - AEC: $aec | CDS: $cds" -foregroundcolor red
		}
	}catch{write-host "$($group) does not exist in CDS" -foregroundcolor yellow}
	
	$aec = $null
	$cds = $null
}