Bird
0
0

You want to move all OUs under 'OU=OldDept,DC=contoso,DC=com' to 'OU=NewDept,DC=contoso,DC=com' using PowerShell. Which script correctly performs this operation?

hard📝 Application Q15 of 15
PowerShell - Active Directory
You want to move all OUs under 'OU=OldDept,DC=contoso,DC=com' to 'OU=NewDept,DC=contoso,DC=com' using PowerShell. Which script correctly performs this operation?
ARename-ADObject -Identity 'OU=OldDept,DC=contoso,DC=com' -NewName 'NewDept'
BMove-ADObject -Identity 'OU=OldDept,DC=contoso,DC=com' -TargetPath 'OU=NewDept,DC=contoso,DC=com'
CGet-ADOrganizationalUnit -Filter * | Move-ADObject -TargetPath 'OU=NewDept,DC=contoso,DC=com'
DGet-ADOrganizationalUnit -SearchBase 'OU=OldDept,DC=contoso,DC=com' | ForEach-Object { Move-ADObject -Identity $_.DistinguishedName -TargetPath 'OU=NewDept,DC=contoso,DC=com' }
Step-by-Step Solution
Solution:
  1. Step 1: Understand the goal

    You want to move all OUs inside 'OldDept' to 'NewDept', not just rename or move 'OldDept' itself.
  2. Step 2: Analyze each option

    Get-ADOrganizationalUnit -SearchBase 'OU=OldDept,DC=contoso,DC=com' | ForEach-Object { Move-ADObject -Identity $_.DistinguishedName -TargetPath 'OU=NewDept,DC=contoso,DC=com' } gets all OUs under 'OldDept' and moves each to 'NewDept' using a loop, which is correct.
    Move-ADObject -Identity 'OU=OldDept,DC=contoso,DC=com' -TargetPath 'OU=NewDept,DC=contoso,DC=com' tries to move 'OldDept' itself, not its child OUs.
    Get-ADOrganizationalUnit -Filter * | Move-ADObject -TargetPath 'OU=NewDept,DC=contoso,DC=com' moves all OUs in the domain, not just under 'OldDept'.
    Rename-ADObject -Identity 'OU=OldDept,DC=contoso,DC=com' -NewName 'NewDept' renames 'OldDept' to 'NewDept', not moving child OUs.
  3. Final Answer:

    Get-ADOrganizationalUnit -SearchBase 'OU=OldDept,DC=contoso,DC=com' | ForEach-Object { Move-ADObject -Identity $_.DistinguishedName -TargetPath 'OU=NewDept,DC=contoso,DC=com' } -> Option D
  4. Quick Check:

    Loop over OUs under OldDept and move each [OK]
Quick Trick: Use Get-ADOrganizationalUnit with ForEach-Object and Move-ADObject [OK]
Common Mistakes:
  • Moving only the parent OU instead of child OUs
  • Moving all OUs in domain unintentionally
  • Using Rename-ADObject instead of Move-ADObject

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes