Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Script to parse .txt & move Computer Accounts to different OU
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Andy. Net  
View profile  
 More options Nov 13 2009, 5:40 am
Newsgroups: microsoft.public.scripting.vbscript
From: Andy.Net <Andy....@discussions.microsoft.com>
Date: Thu, 12 Nov 2009 21:40:01 -0800
Local: Fri, Nov 13 2009 5:40 am
Subject: Script to parse .txt & move Computer Accounts to different OU
I want to move list of computer accounts listed in .txt file to specifid OU
I have refered below script from
http://www.eggheadcafe.com/aspnet_answers/scriptingVisualBasicscript/...  and specify the OU path and .Txt path but getting an error as

Line: 79
Char:1
Error: Expected statement
code: 800A0400
Source: Microsoft VBScript compilation error

******Script****

Option Explicit  

Dim strFile, strTargetOU, objFSO, objFile, objOU  

Dim objRootDSE, strDNSDomain, objTrans, strNetBIOSDomain  

Dim strComputer, strComputerDN, objComputer  

Const ADS_NAME_INITTYPE_DOMAIN = 1  

Const ADS_NAME_TYPE_NT4 = 3  

Const ADS_NAME_TYPE_1179 = 1  

' Specify text file of computer NetBIOS names.  

strFile = "c:\Computers.txt"  

' Specify target OU to move computer objects into.  

strTargetOU = "ou=SrAccounts,dc=MyDomain,dc=com"  

' Open the file for read access.  

Set objFSO = CreateObject("Scripting.FileSystemObject")  

Set objFile = objFSO.OpenTextFile(strFile, 1)  

' Bind to the target OU.  

Set objOU = GetObject("LDAP://" & strTargetOU)  

' Determine DNS domain name from RootDSE object.  

Set objRootDSE = GetObject("LDAP://RootDSE")  

strDNSDomain = objRootDSE.Get("DefaultNamingContext")  

' Use the NameTranslate object to find the NetBIOS domain name from  

' the DNS domain name.  

Set objTrans = CreateObject("NameTranslate")  

objTrans.Init ADS_NAME_TYPE_NT4, strDNSDomain  

objTrans.Set ADS_NAME_TYPE_1179, strDNSDomain  

strNetBIOSDomain = objTrans.Get(ADS_NAME_TYPE_NT4)  

' Remove trailing backslash.  

strNetBIOSDomain = Left(strNetBIOSDomain, Len(strNetBIOSDomain) - 1)  

' Use the NameTranslate object to convert computer NetBIOS  

' names to Distinguished Names.  

objTrans.Init ADS_NAME_INITTYPE_DOMAIN, strNetBIOSDomain  

' Read lines from the file.  

Do Until objFile.AtEndOfStream  

strComputer = Trim(objFile.ReadLine)  

If (strComputer <> "") Then  

' Convert NetBIOS name to DN.  

' NetBIOS name must have "$" appended to end.  

' Trap error if computer not found.  

On Error Resume Next  

objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain _  

& "\" & strComputer & "$"  

If (Err.Number <> 0) Then  

On Error GoTo0  

Wscript.Echo "Computer not found: " & strComputer  

Else  

On Error GoTo 0  

strComputerDN = objTrans.Get(ADS_NAME_TYPE_1179)  

' Bind to the computer object.  

Set objComputer = GetObject("LDAP://" & strComputerDN)  

' Move the computer object to the target OU.  

objTargetOU.MoveHere objComputer.AdsPath, vbNullString  

End If  

End If  

Loop  

Wscript.Echo "Done"  


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andy. Net  
View profile  
 More options Nov 13 2009, 5:55 am
Newsgroups: microsoft.public.scripting.vbscript
From: Andy.Net <Andy...@discussions.microsoft.com>
Date: Thu, 12 Nov 2009 21:55:01 -0800
Local: Fri, Nov 13 2009 5:55 am
Subject: RE: Script to parse .txt & move Computer Accounts to different OU
I got it guys...posted in hurry
No need to reply ;-)


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jason Bosma  
View profile  
 More options Nov 26 2009, 4:49 pm
Newsgroups: microsoft.public.scripting.vbscript
From: Jason Bosma <jbo...@gmail.com>
Date: Thu, 26 Nov 2009 08:49:34 -0800 (PST)
Local: Thurs, Nov 26 2009 4:49 pm
Subject: Re: Script to parse .txt & move Computer Accounts to different OU
On Nov 12, 10:55 pm, Andy.Net <Andy...@discussions.microsoft.com>
wrote:

What did you change?

    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2010 Google