Does computers.txt just contain a list of computer names?

If so, change $computer.CN to simply $computer.

If it is indeed a CSV, you'll need to use import-csv, not get-content.

-----Original Message-----
From: [email protected] [mailto:[email protected]] On 
Behalf Of Kurt Buff
Sent: Friday, November 7, 2014 3:02 PM
To: [email protected]
Subject: [NTSysADM] Powershell simpleton

This is about as simple as it gets, and I'm flummoxed and frustrated.
What on Earth am I doing wrong?

Win7, powershell v2.

I borrowed this script:
http://community.spiceworks.com/topic/508041-bulk-move-computer-objects-powershell

and run it like so (the 3rd line might be wrapped) and get the following error:
     Import-module activedirectory
     $oldcomputers = get-content c:\batchfiles\computers.txt
     foreach ($computer in $oldcomputers){Get-ADComputer $computer.CN
| Move-ADObject -TargetPath 'ou=DeadComputers,dc=example,dc=com' }

Get-ADComputer : Cannot validate argument on parameter 'Identity'. The argument 
is null. Supply a non-null argument and try the command again.
At line:1 char:52
+ foreach ($computer in $oldcomputers){Get-ADComputer <<<<
$computer.CN | Move-ADObject -TargetPath 'ou=DeadComputers,dc=example,dc=com' }
    + CategoryInfo          : InvalidData: (:) [Get-ADComputer],
ParameterBindingValidationException


Reply via email to