• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1719
  • Last Modified:

Powershell script to migrate user from one domain to another then move them to a new group on the new domain

#get list of groups the user belongs to
$GroupNames = Get-QADMemberOf "TestMigration6" -Service "microsoft1.contoso.com" | Select-Object -ExpandProperty Name

#Move the user via admt from domain microsoft1.contoso.com to microsoft2.contoso.com
admt user /N "user1" /IF:YES /MGS:NO /SD: "microsoft1" /TD: "microsoft2" /TO:"test users" /UUR:YES /PO:Complex /FGM:YES

#add user to the groups in microsoft2.contoso.com
$GroupNames | ForEach-Object { Add-QADGroupMember $_ -Member "user1" -Service "microsoft2.contoso.com" }

#this step I need to take it a step further to move the users from the groups they were placed in microsoft2.contoso.com and move them to a group with the same name only GBL_FLS_ is now in front of the name. the example is using dsget but I would like to continue with powershell.
dsgetgroup "$GroupNames" -members | dsmod group "GBL_FLS_$GroupNames
  • 2
1 Solution
Neil RussellTechnical Development LeadCommented:
You could download and use the Quest ad commandlets. I often work with multiple domains in one script using that.

You have the  -service "my.domain.local:389" command switch that allows you to direct each command to a different domain server.

You could do something like...

$D1Users = get-qadgroupmember "Groupname" -service "my.domain.local:389"

foreach ($user in $D1Users) {
$UserName = $user.Displayname
add-qadgroupmember "GBL_FLS_Groupname" $username -service "myOther.domain.local:389"

You would need to be logged in with an account that had domain admin in BOTH domains.
Neil RussellTechnical Development LeadCommented:
Sorry yes, you already have Quest

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now