Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VBScript- Move List of Computers to OU Within another OU

Posted on 2016-09-09
1
Medium Priority
?
77 Views
Last Modified: 2016-09-10
I am working on a script to move computers found in Active Directory to a Disabled Computers OU. The issue I am encountering is that each location has its own OU and the computers must be moved to the Disabled Computers for each location not just a general Disabled Computers OU. For example If a Location is Here then Under Here is the Disabled Computers OU. I am not sure what the proper syntax would be when setting the destination in the script.

I have tried several variations of the following
strNewOU = "LDAP://OU=Here\Disabled Computers," & strDNSDomain
strNewOU = "LDAP://OU=Here\" & """" & "Disabled Computers" & """" & "," & strDNSDomain
strNewOU = "LDAP://OU=Here\Disabled Computers" & strDNSDomain

None of these have worked. Any assistance would be appreciated.
0
Comment
Question by:Frog_1337
1 Comment
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 41792186
Hi, the correct syntax is reverse order, so your structure
Domain.com/Here/Computers/Disabled Computers
Is represented by
strNewOU = "LDAP://OU=Disabled Computers,OU=Computers,OU=Here," & strDNSDomain

Regards,

Rob.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This process allows computer passwords to be managed and secured without using LAPS. This is an improvement on an existing process, enhanced to store password encrypted, instead of clear-text files within SQL
Transferring FSMO roles is done when an admin wants to split roles between certain Domain Controllers or the Domain Controller holding the Roles has been forcefully demoted using dcpromo / forceremoval
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question