Hunter24
asked on
I NEED A SCRIPT IN POWERSHELL TO MOVE INACTIVE COMPUTERS TO ANOTHER OU
I'm trying to complete an AD cleanup. I have already the list of all inactive computers and users that should be moved to another OU, let's call it "DISABLED COMPUTERS" and "DISABLED USERS". This can't be done using GPO and I have no previous experience in scripting, so I will greatly appreciate if anyone of you can provide me a script or the steps to create one that can achieve that purpose. In summary this is what I need:
1. Check for the destination OU if not present create it.
2. Check for the users who meet the criteria if found move to that OU.
3. Check users in the destination OU and if more than x days then delete.
1. Check for the destination OU if not present create it.
2. Check for the users who meet the criteria if found move to that OU.
3. Check users in the destination OU and if more than x days then delete.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
becraig:
Ok. thank you so much. As soon as you have completed it I'll check it.
Ok. thank you so much. As soon as you have completed it I'll check it.
ASKER
RantCan:
Thank you for your posting. I downloaded and tested this Solarwinds tool. The interface is very simple and the query was completed very quickly; it showed me exactly the same results that I got using AD Tidy. However, the only option available is just to remove the inactive computers, I rather prefer to have these objects disabled in another OU and after a certain amount of time delete them. Is there any other free tool that does that and that you recommend?
Thank you for your posting. I downloaded and tested this Solarwinds tool. The interface is very simple and the query was completed very quickly; it showed me exactly the same results that I got using AD Tidy. However, the only option available is just to remove the inactive computers, I rather prefer to have these objects disabled in another OU and after a certain amount of time delete them. Is there any other free tool that does that and that you recommend?
ASKER
Hi becraig:
Do you have the final script so I can test it?
Do you have the final script so I can test it?
I will have it in a bit, sorry was out for the weekend.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
RantCan:
I see what you mean, I need to customize the actions to be executed. That for sure will help me a lot, specially for inactive computers; all inactive user accounts are disabled and they are not as much as computers accounts. However, I still need to find the way to exclude some service accounts that were included in the report. I'll also need to test this in a virtual environment before doing the real thing in a prod environment. Thanks a lot, any other comment or idea is always welcome!
I see what you mean, I need to customize the actions to be executed. That for sure will help me a lot, specially for inactive computers; all inactive user accounts are disabled and they are not as much as computers accounts. However, I still need to find the way to exclude some service accounts that were included in the report. I'll also need to test this in a virtual environment before doing the real thing in a prod environment. Thanks a lot, any other comment or idea is always welcome!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
becraig:
Thanks for your support on this, I'll like to test this script when it is completed. I'm using the AD Tidy app for the cleanup because I need to complete this task next week, after the month closing. However, once this is done I prefer to test this script and put in the the prod environment so that the task is automated. I'll be waiting your feedback.
Thanks for your support on this, I'll like to test this script when it is completed. I'm using the AD Tidy app for the cleanup because I need to complete this task next week, after the month closing. However, once this is done I prefer to test this script and put in the the prod environment so that the task is automated. I'll be waiting your feedback.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you all, becraig did a great job with the script but I prefered to use a simpler solution as the one recommended by RantCan
ASKER
I'll be using the "not logged on for X days" qualifier. I have more than 80 machines that are inactive but not being flagged at all. All inactive users are now disabled but I'll need to move them to an OU and after a year of these accounts become inactive proceed to delete them. Just let me know what else is needed. Thank you.