Created domain account in each domain add it to domain admin group
$domains = (get-adforest).domains
foreach($domain in $domains){
$accountname = ‘s-coe-‘+($domain -split “.”)[0]+’-DA’
$accountpass = ‘P@ssword123456’ | ConvertTo-SecureString -Force -AsPlainText
Write-Output “Working on $domain – DA is $accountname”
New-ADUser -name $accountname -SamAccountName $accountname -AccountPassword $accountpass -Enabled $true -Server $domain
start-sleep -Seconds 5
Add-ADGroupMember -Identity “Domain Admins” -Members $accountname -Server $domain
}
Remove domain account in each domain
$domains = (get-adforest).domains
foreach($domain in $domains){
$accountname = ‘s-coe-‘+($domain -split “.”)[0]+’-DA’
get-aduser $accountname -Server $domain | Remove-ADUser -Server $domain -Verbose -Confirm:$false
}