Move bulk computer objects listed in TXT file to specific OU in Active Directory
- List down the servers you want to move in a file named "server.txt".
- Then find the correct OU where you want to move all computer objects.
- Note: We assume we need to move the computer accounts in Servers OU under the nilabh.com domain.
- Run the following script to move all computer objects listed in the notepad file to the required OU.
$Servers = Get-Content "C:\servers.txt"
$TargetOU = "OU=Servers,DC=nilabh,DC=com"
ForEach( $Computer in $Servers ) {
Get-ADComputer $Computer | Move-ADObject -TargetPath $TargetOU
}
Comments
Post a Comment