You can try each of these; they all should work:
# Ugly
$sessionOB = New-PSSession -ComputerName $domainComputer -Credential $domainCreds
Invoke-Command -Session $sessionOB -ScriptBlock {
$args[0] | ForEach-Object {
Add-LocalGroupMember -Group "Administrators" -Member $_ -Confirm:$false
}
} -ArgumentList (,$ADGroups)
# Better
$sessionOB = New-PSSession -ComputerName $domainComputer -Credential $domainCreds
Invoke-Command -Session $sessionOB -ScriptBlock {
$Using:ADgroups | ForEach-Object {
Add-LocalGroupMember -Group "Administrators" -Member $_ -Confirm:$false
}
}
# Probably the best
$sessionOB = New-PSSession -ComputerName $domainComputer -Credential $domainCreds
Invoke-Command -Session $sessionOB -ScriptBlock {
Add-LocalGroupMember -Group "Administrators" -Member $Using:ADGroups -Confirm:$false
}