Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Move Computers from Text File to OU - PowerShell

$
0
0

I have a text file in the following format:

Computer01

Computer02

I'm trying run this PowerShell Script against it that moves any computer name in the file over to the Dormant OU in our environment:

Import-module ActiveDirectory

$computerObjects = get-content C:\ComputerNames.txt

ForEach($computerObject in $computerObjects)

{Move-ADObject $computerObject -TargetPath "OU=Dormant, DC=company, DC=com"}

When I run it, I get the following error message:

"Move-ADObject : Cannot find an object with identity: 'Computer1' under: 'DC=company,DC=com'."

Can you provide some insight on the situation?  Thanks!


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>