Hi, first off let me say I'm a total novice and am looking for a decent book - any recommendations? I'm considering the following: 1) AD Cookbook - Robbie ALlen 2) AD 3rd Ed - Joe Richards 3) AD - Robbie Allen/ Alistair Lowe-Norris May not be the right newsgroup for this tho..
So, to my question... I am trying to script moving multiple computer accounts from unknown OU's to a known OU within one domain in AD. I have created a list of these computers that I want to move. I have found a script in the script centre:
I then found this post which details writing a batch file and using an input file:
1 input.txt
computer_name_1 computer:name_2
2 the batch file
@echo off
echo **************************************** Echo * script to move computers* echo ****************************************
for /F %%1 in (input.txt) do ( cscript move_cmp.vbs %%1 //B //Nologo >> err_log.txt 2>>&1 )
3 the VBS move_cmp.vbs FILE
dim nomepc ParseCommandLine()
Const ADS_PROPERTY_APPEND = 3 Set objRootDSE = GetObject("LDAP://rootDSE")
'************************************************************************** *** '* INTO STRVARIABL LINE PUT THE PATH WHERE THE object will be moved '* (EX: strVariabl = ",OU=Standard Users,OU=DomainNAME,") '************************************************************************** *** '************************************************************************** *** strVariabl = "OU=Public Desktops,OU=PIPPO,OU=PIPPO" '************************************************************************** *** '************************************************************************** *** '************************************************************************** *** strFissa = strVariabl & "," & objRootDSE.Get("defaultNamingContext") wscript.echo strFissa
Set objNewOU = GetObject("LDAP://"& strFissa) Set objMoveComputer = objNewOU.MoveHere _ ("LDAP://CN="& nomepc & ",CN=Computers," & objRootDSE.Get("defaultNamingContext"), "CN=" &nomepc)
Sub ParseCommandLine() Dim vArgs
set vArgs = WScript.Arguments
if vArgs.Count <> 1 then DisplayUsage() Else nomepc = vArgs(0) End if End Sub
I've not changed any of the variables here but this script only looks in the computers container and not throught the entire AD structure. Ideally I would like either the first script to use a lookup file or the 2nd script to search the entire AD but my knowledge does not extend that far. I'd be very grateful for any help. Thanks
If you want to know how AD works I have Joe Richards' book and like it. If you want to learn how to script administrative tasks I'd recommend "Micrsoft Windows 2000 Scripting Guide - Automating System Administration". I have the book, but it's also available online at:
A quick look at your script and it seems OK, but definitely remove the "On Error Resume Next" statement. It is not needed and makes the script ignore all errors. This makes troubleshooting impossible. If you run the script without this statement and get an error message, you have something to fix.
I assume you have a text file with the NetBIOS names of computers. I would use NameTranslate rather than ADO for this, as it seems more efficient. I have used code similar to below: =================== Option Explicit
Dim strFile, strTargetOU, objFSO, objFile, objOU Dim objRootDSE, strDNSDomain, objTrans, strNetBIOSDomain Dim strComputer, strComputerDN, objComputer
' Specify text file of computer NetBIOS names. strFile = "c:\scripts\Computers.txt"
' Specify target OU to move computer objects into. strTargetOU = "Detention,ou=West,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" ============= You need only modify the file name and the Distinguished Name of the target OU. This script figures out the domain. Notice also that I bind to the computer object, so I know I get the correct AdsPath. Sometimes this makes a difference. I believe NameTranslate is more efficient than ADO.
> Hi, > first off let me say I'm a total novice and am looking for a decent book - > any recommendations? I'm considering the following: > 1) AD Cookbook - Robbie ALlen > 2) AD 3rd Ed - Joe Richards > 3) AD - Robbie Allen/ Alistair Lowe-Norris > May not be the right newsgroup for this tho..
> So, to my question... > I am trying to script moving multiple computer accounts from unknown OU's > to > a known OU within one domain in AD. > I have created a list of these computers that I want to move. > I have found a script in the script centre:
> objCommand.CommandText = _ > "SELECT ADsPath FROM 'LDAP://dc=domain,dc=com' WHERE > objectCategory='computer' " & _ > "AND Name='computenamer'" > Set objRecordSet = objCommand.Execute
> objRecordSet.MoveFirst
> Do Until objRecordSet.EOF > strADsPath = objRecordSet.Fields("ADsPath").Value > objOU.MoveHere strADsPath, vbNullString > objRecordSet.MoveNext > Loop >>>finish > http://www.microsoft.com/technet/scriptcenter/resources/qanda/jun06/h... > (I've changed computername and domainname) > Now this is supposed to move a comp account from an unknown OU to known OU > however I tested this with one computer account and it didn't work.
> I then found this post which details writing a batch file and using an > input > file:
> if vArgs.Count <> 1 then > DisplayUsage() > Else > nomepc = vArgs(0) > End if > End Sub
> I've not changed any of the variables here but this script only looks in > the > computers container and not throught the entire AD structure. > Ideally I would like either the first script to use a lookup file or the > 2nd > script to search the entire AD but my knowledge does not extend that far. > I'd be very grateful for any help. > Thanks
Richard, You are a diamond - that worked a treat. The tip of removing the "on error resume next" was great by itself as I could see where things were failing- for starters I had the path of the OU slightly jumbled... Also managed to fix a couple of errors in the script you gave me:
line 52 needed a space: On Error GoTo 0 line 60 needed to change objTargetOU to objOU as was giving an error saying objTargetOU wasn't defined (which of course it wasn't)
Thanks also for the recommendations re books, now just need to find an extra few hours in the day! Cheers Rob
> Richard, > You are a diamond - that worked a treat. > The tip of removing the "on error resume next" was great by itself as I > could see where things were failing- for starters I had the path of the OU > slightly jumbled... > Also managed to fix a couple of errors in the script you gave me:
> line 52 needed a space: On Error GoTo 0 > line 60 needed to change objTargetOU to objOU as was giving an error > saying > objTargetOU wasn't defined (which of course it wasn't)
> Thanks also for the recommendations re books, now just need to find an > extra > few hours in the day! > Cheers > Rob
Richard this is a great script and saved my butt last weekend.
I need to run it on about 1000 pc's next week and would like to get a text output of the machines as it goes through the list of pc's. (I thought I could add that part myself but haven't been successful.) Any quick and efficient ideas?
"Richard Mueller" wrote: > Nice work catching the errors. I put that together too fast.
> Richard
> "Rob" <R...@discussions.microsoft.com> wrote in message > news:3A26881B-09BC-4ED2-AE08-9A3F7CE24C87@microsoft.com... > > Richard, > > You are a diamond - that worked a treat. > > The tip of removing the "on error resume next" was great by itself as I > > could see where things were failing- for starters I had the path of the OU > > slightly jumbled... > > Also managed to fix a couple of errors in the script you gave me:
> > line 52 needed a space: On Error GoTo 0 > > line 60 needed to change objTargetOU to objOU as was giving an error > > saying > > objTargetOU wasn't defined (which of course it wasn't)
> > Thanks also for the recommendations re books, now just need to find an > > extra > > few hours in the day! > > Cheers > > Rob
> Richard this is a great script and saved my butt last weekend.
> I need to run it on about 1000 pc's next week and would like to get a > text output of the machines as it goes through the list of pc's. (I > thought I > could add that part myself but haven't been successful.) > Any quick and efficient ideas?
> "Richard Mueller" wrote:
>> Nice work catching the errors. I put that together too fast.
>> Richard
>> "Rob" <R...@discussions.microsoft.com> wrote in message >> news:3A26881B-09BC-4ED2-AE08-9A3F7CE24C87@microsoft.com... >> > Richard, >> > You are a diamond - that worked a treat. >> > The tip of removing the "on error resume next" was great by itself as >> > I >> > could see where things were failing- for starters I had the path of the >> > OU >> > slightly jumbled... >> > Also managed to fix a couple of errors in the script you gave me:
>> > line 52 needed a space: On Error GoTo 0 >> > line 60 needed to change objTargetOU to objOU as was giving an error >> > saying >> > objTargetOU wasn't defined (which of course it wasn't)
>> > Thanks also for the recommendations re books, now just need to find an >> > extra >> > few hours in the day! >> > Cheers >> > Rob
The easiest way to have the script document what happens (to a text file) is to use Wscript.Echo statements, run the script at a command prompt using cscript, and redirect the output to a text file. The script already echos when a computer is not found, so you can add a Wscript.Echo statement where the script moves computers. If the script is saved in the file MoveComputers.vbs you can use a command similar to below at a command prompt:
cscript //nologo MoveComputers.vbs > report.txt
The "//nologo" parameter suppresses logo information. It takes more work to use the FileSystemObject to create and write to a log file, but this offers more flexibility. You can also both echo to the console and write to the file, so you can monitor progress as the script runs (and not worry if it is hung up), while still having a log for later. The version below (corrected for the mistakes found earlier), both echos to the console and writes to a file. No need to redirect the output. The name and path of the files are hard coded: =========== Option Explicit
Dim strFile, strTargetOU, objFSO, objFile, objOU Dim objRootDSE, strDNSDomain, objTrans, strNetBIOSDomain Dim strComputer, strComputerDN, objComputer Dim strLog, objLog
' Specify target OU to move computer objects into. strTargetOU = "ou=Detention,ou=West,dc=MyDomain,dc=com"
' Open the file for read access. Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile(strFile, ForReading)
' Open the log file for appending. Set objLog = objFSO.OpentTextFile(strlog, _ ForAppending, CreateIfNotExist, OpenAsASCII) ' Write to the log file. objLog.WriteLine "MoveComputers.vbs log file" objLog.WriteLine "Started: " & CStr(Now())
' 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 GoTo 0 Wscript.Echo "Computer not found: " & strComputer objLog.WriteLine strComputer & " not found" 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. objOU.MoveHere objComputer.AdsPath, vbNullString Wscript.Echo strComputer & " moved" objLog.WriteLine strComputer & " moved" End If End If Loop
> Richard this is a great script and saved my butt last weekend.
> I need to run it on about 1000 pc's next week and would like to get a > text output of the machines as it goes through the list of pc's. (I > thought I > could add that part myself but haven't been successful.) > Any quick and efficient ideas?
> "Richard Mueller" wrote:
>> Nice work catching the errors. I put that together too fast.
>> Richard
>> "Rob" <R...@discussions.microsoft.com> wrote in message >> news:3A26881B-09BC-4ED2-AE08-9A3F7CE24C87@microsoft.com... >> > Richard, >> > You are a diamond - that worked a treat. >> > The tip of removing the "on error resume next" was great by itself as >> > I >> > could see where things were failing- for starters I had the path of the >> > OU >> > slightly jumbled... >> > Also managed to fix a couple of errors in the script you gave me:
>> > line 52 needed a space: On Error GoTo 0 >> > line 60 needed to change objTargetOU to objOU as was giving an error >> > saying >> > objTargetOU wasn't defined (which of course it wasn't)
>> > Thanks also for the recommendations re books, now just need to find an >> > extra >> > few hours in the day! >> > Cheers >> > Rob
>> I need to run it on about 1000 pc's next week and would like to get >> a >> text output of the machines as it goes through the list of pc's. (I >> thought I >> could add that part myself but haven't been successful.) >> Any quick and efficient ideas?
>> "Richard Mueller" wrote:
>>> Nice work catching the errors. I put that together too fast.
>>> Richard
>>> "Rob" <R...@discussions.microsoft.com> wrote in message >>> news:3A26881B-09BC-4ED2-AE08-9A3F7CE24C87@microsoft.com... >>> > Richard, >>> > You are a diamond - that worked a treat. >>> > The tip of removing the "on error resume next" was great by itself as >>> > I >>> > could see where things were failing- for starters I had the path of >>> > the OU >>> > slightly jumbled... >>> > Also managed to fix a couple of errors in the script you gave me:
>>> > line 52 needed a space: On Error GoTo 0 >>> > line 60 needed to change objTargetOU to objOU as was giving an error >>> > saying >>> > objTargetOU wasn't defined (which of course it wasn't)
>>> > Thanks also for the recommendations re books, now just need to find an >>> > extra >>> > few hours in the day! >>> > Cheers >>> > Rob
Richard, I tried running the script usicng Cscript and got the following error: C:\Lee\moveou.vbs(30, 1) Microsoft VBScript runtime error: Object doesn't support this property or method: 'OpentTextFile'
I tried creating the Movedcomputer.log file but got the same error. I have only changed the file locations and the OU path to suit our environment.
"Richard Mueller [MVP]" wrote: > The easiest way to have the script document what happens (to a text file) is > to use Wscript.Echo statements, run the script at a command prompt using > cscript, and redirect the output to a text file. The script already echos > when a computer is not found, so you can add a Wscript.Echo statement where > the script moves computers. If the script is saved in the file > MoveComputers.vbs you can use a command similar to below at a command > prompt:
> cscript //nologo MoveComputers.vbs > report.txt
> The "//nologo" parameter suppresses logo information. It takes more work to > use the FileSystemObject to create and write to a log file, but this offers > more flexibility. You can also both echo to the console and write to the > file, so you can monitor progress as the script runs (and not worry if it is > hung up), while still having a log for later. The version below (corrected > for the mistakes found earlier), both echos to the console and writes to a > file. No need to redirect the output. The name and path of the files are > hard coded: > =========== > Option Explicit
> Dim strFile, strTargetOU, objFSO, objFile, objOU > Dim objRootDSE, strDNSDomain, objTrans, strNetBIOSDomain > Dim strComputer, strComputerDN, objComputer > Dim strLog, objLog
> ' Specify target OU to move computer objects into. > strTargetOU = "ou=Detention,ou=West,dc=MyDomain,dc=com"
> ' Open the file for read access. > Set objFSO = CreateObject("Scripting.FileSystemObject") > Set objFile = objFSO.OpenTextFile(strFile, ForReading)
> ' Open the log file for appending. > Set objLog = objFSO.OpentTextFile(strlog, _ > ForAppending, CreateIfNotExist, OpenAsASCII) > ' Write to the log file. > objLog.WriteLine "MoveComputers.vbs log file" > objLog.WriteLine "Started: " & CStr(Now())
> ' 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 GoTo 0 > Wscript.Echo "Computer not found: " & strComputer > objLog.WriteLine strComputer & " not found" > 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. > objOU.MoveHere objComputer.AdsPath, vbNullString > Wscript.Echo strComputer & " moved" > objLog.WriteLine strComputer & " moved" > End If > End If > Loop
> > I need to run it on about 1000 pc's next week and would like to get a > > text output of the machines as it goes through the list of pc's. (I > > thought I > > could add that part myself but haven't been successful.) > > Any quick and efficient ideas?
> > "Richard Mueller" wrote:
> >> Nice work catching the errors. I put that together too fast.
> >> Richard
> >> "Rob" <R...@discussions.microsoft.com> wrote in message > >> news:3A26881B-09BC-4ED2-AE08-9A3F7CE24C87@microsoft.com... > >> > Richard, > >> > You are a diamond - that worked a treat. > >> > The tip of removing the "on error resume next" was great by itself as > >> > I > >> > could see where things were failing- for starters I had the path of the > >> > OU > >> > slightly jumbled... > >> > Also managed to fix a couple of errors in the script you gave me:
> >> > line 52 needed a space: On Error GoTo 0 > >> > line 60 needed to change objTargetOU to objOU as was giving an error > >> > saying > >> > objTargetOU wasn't defined (which of course it wasn't)
> >> > Thanks also for the recommendations re books, now just need to find an > >> > extra > >> > few hours in the day! > >> > Cheers > >> > Rob
"lee" wrote: > Richard, > I tried running the script usicng Cscript and got the following error: > C:\Lee\moveou.vbs(30, 1) Microsoft VBScript runtime error: Object doesn't > support this property or method: 'OpentTextFile'
> I tried creating the Movedcomputer.log file but got the same error. I have > only changed the file locations and the OU path to suit our environment.
> "Richard Mueller [MVP]" wrote:
> > The easiest way to have the script document what happens (to a text file) is > > to use Wscript.Echo statements, run the script at a command prompt using > > cscript, and redirect the output to a text file. The script already echos > > when a computer is not found, so you can add a Wscript.Echo statement where > > the script moves computers. If the script is saved in the file > > MoveComputers.vbs you can use a command similar to below at a command > > prompt:
> > The "//nologo" parameter suppresses logo information. It takes more work to > > use the FileSystemObject to create and write to a log file, but this offers > > more flexibility. You can also both echo to the console and write to the > > file, so you can monitor progress as the script runs (and not worry if it is > > hung up), while still having a log for later. The version below (corrected > > for the mistakes found earlier), both echos to the console and writes to a > > file. No need to redirect the output. The name and path of the files are > > hard coded: > > =========== > > Option Explicit
> > Dim strFile, strTargetOU, objFSO, objFile, objOU > > Dim objRootDSE, strDNSDomain, objTrans, strNetBIOSDomain > > Dim strComputer, strComputerDN, objComputer > > Dim strLog, objLog
> > ' Specify target OU to move computer objects into. > > strTargetOU = "ou=Detention,ou=West,dc=MyDomain,dc=com"
> > ' Open the file for read access. > > Set objFSO = CreateObject("Scripting.FileSystemObject") > > Set objFile = objFSO.OpenTextFile(strFile, ForReading)
> > ' Open the log file for appending. > > Set objLog = objFSO.OpentTextFile(strlog, _ > > ForAppending, CreateIfNotExist, OpenAsASCII) > > ' Write to the log file. > > objLog.WriteLine "MoveComputers.vbs log file" > > objLog.WriteLine "Started: " & CStr(Now())
> > ' 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 GoTo 0 > > Wscript.Echo "Computer not found: " & strComputer > > objLog.WriteLine strComputer & " not found" > > 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. > > objOU.MoveHere objComputer.AdsPath, vbNullString > > Wscript.Echo strComputer & " moved" > > objLog.WriteLine strComputer & " moved" > > End If > > End If > > Loop
> > > I need to run it on about 1000 pc's next week and would like to get a > > > text output of the machines as it goes through the list of pc's. (I > > > thought I > > > could add that part myself but haven't been successful.) > > > Any quick and efficient ideas?
> > > "Richard Mueller" wrote:
> > >> Nice work catching the errors. I put that together too fast.
> > >> Richard
> > >> "Rob" <R...@discussions.microsoft.com> wrote in message > > >> news:3A26881B-09BC-4ED2-AE08-9A3F7CE24C87@microsoft.com... > > >> > Richard, > > >> > You are a diamond - that worked a treat. > > >> > The tip of removing the "on error resume next" was great by itself as > > >> > I > > >> > could see where things were failing- for starters I had the path of the > > >> > OU > > >> > slightly jumbled... > > >> > Also managed to fix a couple of errors in the script you gave me:
> > >> > line 52 needed a space: On Error GoTo 0 > > >> > line 60 needed to change objTargetOU to objOU as was giving an error > > >> > saying > > >> > objTargetOU wasn't defined (which of course it wasn't)
> > >> > Thanks also for the recommendations re books, now just need to find an > > >> > extra > > >> > few hours in the day! > > >> > Cheers > > >> > Rob
I need to be able to move computer accounts from one OU to another as well, but I need the script to search for specific computer names in the Computers OU for computers that have joined the domain. Any computers that start with "L1", move it to the correct OU. I also need it to run in real-time once the computer has joined to the domain.
"Richard Mueller" wrote: > Nice work catching the errors. I put that together too fast.
> Richard
> "Rob" <R...@discussions.microsoft.com> wrote in message > news:3A26881B-09BC-4ED2-AE08-9A3F7CE24C87@microsoft.com... > > Richard, > > You are a diamond - that worked a treat. > > The tip of removing the "on error resume next" was great by itself as I > > could see where things were failing- for starters I had the path of the OU > > slightly jumbled... > > Also managed to fix a couple of errors in the script you gave me:
> > line 52 needed a space: On Error GoTo 0 > > line 60 needed to change objTargetOU to objOU as was giving an error > > saying > > objTargetOU wasn't defined (which of course it wasn't)
> > Thanks also for the recommendations re books, now just need to find an > > extra > > few hours in the day! > > Cheers > > Rob