Link to home
Start Free TrialLog in
Avatar of Samson AOD
Samson AOD

asked on

Need powershell help to move a list of computers into a corresponding list of OU's

I've dug in and found this much of the puzzle

$ComputersPath= Import-Csv -Path "C:\Users\Computernames\Computers.csv"
$TargetOU = "OU=funtimes,DC=test,DC=local"
foreach ($item in $ComputersPath){
	
    $computer = Get-ADComputer $item.CompName

    Move-ADObject -Identity $computer.DistinguishedName -TargetPath $TargetOU -Confirm:$false

    Write-Host Computer account $computer.Name has been moved successfully

Open in new window

This reads a .csv file full of computer names and moves them to the "$TargetOU", but I have another .csv file that contains a list of OU's that each machine needs to be moved to.
Avatar of J0rtIT
J0rtIT
Flag of Venezuela, Bolivarian Republic of image

can you post at least 2 lines of your 'container' of the OUs?  just need the name of the fields at the top.
ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Samson AOD
Samson AOD

ASKER

Perfect this was exactly what I needed Thank you!