AD copy account memebership
-
looking at this script is there a way to make it so it works on two domians? ex from is domain A to is domain B.
There is a trust in place, and can be done manually but it's a lot of work to do manually.
-
If not does anyone know something to accomplish this?
-
It could probably be done... What are you trying to do? Copy user groups from Domain A to Domain B?
-
@dafyre said:
It could probably be done... What are you trying to do? Copy user groups from Domain A to Domain B?
No, just copy the member ship from User account in Domain A to User accounts in Domain B. Groups will stay on domain A, and users in domain b will become members.
-
So wait... you want to copy the group membership from DOMAINA\jane.doe to DOMAINB\john.smith ?
-
This one should be easier to modify if I can figure out how and would be better anyway. I just need to figure out how to make the second account from another domain.
import-module ActiveDirectory cls write-output "This script adds the destination user to all the Groups which the source user is memberof." write-output " " write-output " " $SName = Read-Host "Please Enter the alias name of the source user " $DName = Read-Host "Please Enter the alias name of the Destination user " $K = Get-ADUser -Identity $SName -Properties memberOf foreach($group in $K.memberof) { Add-ADGroupMember -Identity $group -Member $DName write-output $group }
-
@dafyre said:
So wait... you want to copy the group membership from DOMAINA\jane.doe to DOMAINB\john.smith ?
Basically.
-
This worked
import-module ActiveDirectory cls write-output "This script adds the destination user to all the Groups which the source user is memberof." write-output " " write-output " " $SName = Read-Host "Please Enter the alias name of the source user " $DName = Read-Host "Please Enter the alias name of the Destination user " $DN = Get-ADUser $DName -Server DOMAINBDC $K = Get-ADUser -Identity $SName -Properties memberOf foreach($group in $K.memberof) { Add-ADGroupMember -Identity $group -Member $DN write-output $group }