Quantcast
Channel: Directory Services forum
Viewing all articles
Browse latest Browse all 31638

Moving computer objects using PowerShell

$
0
0

Hi everyone

I have a PowerShell script that I've cobbled together as I am new to coding, it's purpose is to reference a text file containing computer object names then move them to a specific container. It works absolutly fine, trouble is some of the objects it comes up against may be protected from deletion so they can't be moved. I can see which machines cannot be moved in the output window, what I would like is for the script to create an error log of all the machines it couldn't move. I can then use this error text file on another script which unchecks the accidental deletion box.

Here is the script:

Import-Module ActiveDirectory

$COMPUTERS = get-content \\path\CompObjects.txt
$COMPUTERS|Foreach{Get-ADComputer $_ | Move-ADObject -TargetPath "OU=Disabled Computers (Win 7),OU=Disabled Accounts,OU=All Computers,DC=**,DC=**,DC=**"}

Thanks in advance for any advice given!!


Viewing all articles
Browse latest Browse all 31638

Trending Articles



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