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
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect this was exactly what I needed Thank you!