Hi,
I hope someone can put me in the right direction here, Im playing with some code I found, that copies AD groups from one user to another.
So far I have this
Import AD commands
import-Module ActiveDirectory
Login name of user to copy FROM
$copyfrom = Read-host "Enter username to copy from: "
Login name of user to copy TO
$pasteto = Read-host "Enter username to copy to: "
Get membership of FROM and add to
get-ADuser -Server “dc01.Domain.co.uk” -identity $copyfrom -properties memberof | select-object memberof -expandproperty memberof | Add-AdGroupMember -Server “dc01.Domain.co.uk” -Members $pasteto
This is working but the issue I have, is that some groups exisit in another domain ie Domain2 and I get an error, how do I get the code to check all our domains, instead of restricting my self to one domain in the -server parameter.
thank you in advance