Imagine the following situation: You want to bulk move Computers to different OU.
You already use a tool to check your Active Directory for inactive devices (e.g. Last Logon Date 100 days before). This tool offers the possibility to export these old computers to a .TXT file. Before deleting them completely, you may want to move them to a different Organizational Unit (OU) to keep them for a few more days. Instead of moving them manually, use this simple PowerShell script which accepts a .TXT file as input, reads the computer names line by line and loops through them.
# Specify path to the text file with the computer account names. $computers = Get-Content \\PathToScript\ComputersToDelete.txt # Specify path to the OU where computers will be moved. $TargetOU = "OU=Users,OU=<SubUnit>,OU=<MainUnit>,DC=<domainName>,DC=com" # Move Computers to the new OU ForEach($computer in $computers){ Get-ADComputer $computer | Move-ADObject -TargetPath $TargetOU }
Of course you could combine that with the following script: Get Inactive Computers
If you are interested in the full possibilites of Get-ADComputer, you can check Microsoft Docs to Move Computers to different OU