I have a text file with 1 computer name in it. I want to read this .txt file and for all machines within it move them to a new OU in AD.
$NewOU = [ADSI]"LDAP://OU=_Test,OU=LaptopComputers,OU=BakerINC,DC=COM"
$PCS=Get-Content C:\temp\Machine.txt
foreach ($computerToMove in $PCS) {
Move-ADObject $computerToMove $NewOU }
I run this above script and I get the following error.
Move-ADObject : Cannot find an object with identity: 'BAKLTBOS14' under:
'DC=BakerINC,DC=com'.
At C:\Temp\try4.ps1:13 char:5
+ Move-ADObject $computerToMove $NewOU }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (BAKLTBOS14:ADObject) [Move
-ADObject], ADIdentityNotFoundException
+ FullyQualifiedErrorId : Cannot find an object with identity: 'SFRWLMQHAR
RIN01' under: 'DC=BakerINC,DC=com'.,Microsoft.ActiveDirectory.Management.Co
mmands.MoveADObject
the computer named BAKLTBOS14 is in AD and it's a live machine so what causes this error?
$NewOU = [ADSI]"LDAP://OU=_Test,OU=LaptopComputers,OU=BakerINC,DC=COM"
$PCS=Get-Content C:\temp\Machine.txt
foreach ($computerToMove in $PCS) {
Move-ADObject $computerToMove $NewOU }
I run this above script and I get the following error.
Move-ADObject : Cannot find an object with identity: 'BAKLTBOS14' under:
'DC=BakerINC,DC=com'.
At C:\Temp\try4.ps1:13 char:5
+ Move-ADObject $computerToMove $NewOU }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (BAKLTBOS14:ADObject) [Move
-ADObject], ADIdentityNotFoundException
+ FullyQualifiedErrorId : Cannot find an object with identity: 'SFRWLMQHAR
RIN01' under: 'DC=BakerINC,DC=com'.,Microsoft.ActiveDirectory.Management.Co
mmands.MoveADObject
the computer named BAKLTBOS14 is in AD and it's a live machine so what causes this error?
mqh7