Re: [ActiveDir] ok, last one really
quick question- what does your script do if the server is offline or can't be accessed for some reason? does it just go to the next server in the list? How long does it try to connect for? Thanks On 8/15/05, Tom Kern [EMAIL PROTECTED] wrote: So, if i set a dns addy and then change it or use dhcp to set it, windows will still keep a phantom reference to it in the registry? is there a normal procedure to whack it? On 8/15/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: probably because those addresses are still in the registry and have not been whacked. Sincerely, Dиjм Akуmцlбfй, MCSE+M MCSA+M MCP+I Microsoft MVP - Directory Services www.readymaids.com - we know IT www.akomolafe.com Do you now realize that Today is the Tomorrow you were worried about Yesterday? -anon From: [EMAIL PROTECTED] on behalf of Tom Kern Sent: Mon 8/15/2005 12:11 PM To: ActiveDir@mail.activedir.org Subject: Re: [ActiveDir] ok, last one really This script gives me the client dns ip's that are there as well as ones that haven't been there in a long time. one's i set and removed awhile ago. why is that? thanks On 8/15/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: What, you mean you don't trust my codes? Shesh! :-p 'Still using the same folder structure and input file as before, you will run this AFTER running the previous script 'Code Begins Const FILEPATH = C:\MyScripts\ 'Get the input file Set FSO = CreateObject(Scripting.FileSystemObject) Set fsoFile = FSO.GetFile(FILEPATH Server-List.txt) strFilePath = fsoFile.Path Set fsoInput = FSO.OpenTextFile(strFilePath, 1) Set FSOWrite=FSO.OpenTextFile(FILEPATH Output.txt, 8, True) Do While Not fsoInput.AtEndOfStream ComputerName = fsoInput.ReadLine FSOWrite.WriteLine ComputerName Call ChangeDNS_addy(ComputerName) Loop FSOWrite.Close Set FSOWrite = Nothing Set fsoInput = Nothing Set fsoFile = Nothing set FSO=Nothing Sub ChangeDNS_addy(ComputerName) On Error Resume Next Set objWMIService = GetObject(winmgmts:\\ ComputerName \root\cimv2) Set colNetCards = objWMIService.ExecQuery _ (Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True) For Each objNetCard in colNetCards If Not IsNull(objNetCard.DNSServerSearchOrder) Then For i = 0 To UBound(objNetCard.DNSServerSearchOrder) FSOWrite.WriteLine vbTab objNetCard.DNSServerSearchOrder(i) Next End If Next Set colNetCards = Nothing Set objWMIService = Nothing End Sub 'Code Ends Sincerely, Dиjм Akуmцlбfй, MCSE+M MCSA+M MCP+I Microsoft MVP - Directory Services www.readymaids.com - we know IT www.akomolafe.com Do you now realize that Today is the Tomorrow you were worried about Yesterday? -anon From: [EMAIL PROTECTED] on behalf of Tom Kern Sent: Mon 8/15/2005 7:57 AM To: ActiveDir@mail.activedir.org Subject: Re: [ActiveDir] ok, last one really Now how can I write a script or modify that to tell me it worked? Do i need to write a new script to query the client dns ip's and feed it the same file and spit that out to a text file so i can see it took? thanks On 8/14/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Let's say the new DNS servers are 192.168.11.250 and 192.168.11.251 Let's say you have a folder called Myscripts in C:\ You create a file called Server-List.txt that contains all your servers' names, listed one per line and put it in C:\myscripts Then you copy the following code, put it in a file and call the file, say, change-dns.vbs Off you go. 'Code starts here Const FILEPATH = C:\MyScripts\ 'Get the input file Set FSO = CreateObject(Scripting.FileSystemObject) Set fsoFile = FSO.GetFile(FILEPATH Server-List.txt) strFilePath = fsoFile.Path Set fsoInput = FSO.OpenTextFile(strFilePath, 1) Do While Not fsoInput.AtEndOfStream ComputerName = fsoInput.ReadLine Call ChangeDNS_addy(ComputerName) Loop Set fsoInput = Nothing Set fsoFile = Nothing set FSO=Nothing Sub ChangeDNS_addy(ComputerName) On Error Resume Next Set objWMIService = GetObject(winmgmts:\\ ComputerName \root\cimv2) Set colNetCards = objWMIService.ExecQuery _ (Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True) For Each objNetCard in colNetCards arrDNSServers = Array(192.168.11.250, 192.168.11.251) objNetCard.SetDNSServerSearchOrder(arrDNSServers) Next Set colNetCards = Nothing Set objWMIService = Nothing End Sub 'code ends Enjoy. Sincerely, Dиjм Akуmцlбfй, MCSE+M MCSA+M MCP+I Microsoft MVP - Directory Services www.readymaids.com - we know IT www.akomolafe.com
Re: [ActiveDir] ok, last one really
Now how can I write a script or modify that to tell me it worked? Do i need to write a new script to query the client dns ip's and feed it the same file and spit that out to a text file so i can see it took? thanks On 8/14/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Let's say the new DNS servers are 192.168.11.250 and 192.168.11.251 Let's say you have a folder called Myscripts in C:\ You create a file called Server-List.txt that contains all your servers' names, listed one per line and put it in C:\myscripts Then you copy the following code, put it in a file and call the file, say, change-dns.vbs Off you go. 'Code starts here Const FILEPATH = C:\MyScripts\ 'Get the input file Set FSO = CreateObject(Scripting.FileSystemObject) Set fsoFile = FSO.GetFile(FILEPATH Server-List.txt) strFilePath = fsoFile.Path Set fsoInput = FSO.OpenTextFile(strFilePath, 1) Do While Not fsoInput.AtEndOfStream ComputerName = fsoInput.ReadLine Call ChangeDNS_addy(ComputerName) Loop Set fsoInput = Nothing Set fsoFile = Nothing set FSO=Nothing Sub ChangeDNS_addy(ComputerName) On Error Resume Next Set objWMIService = GetObject(winmgmts:\\ ComputerName \root\cimv2) Set colNetCards = objWMIService.ExecQuery _ (Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True) For Each objNetCard in colNetCards arrDNSServers = Array(192.168.11.250, 192.168.11.251) objNetCard.SetDNSServerSearchOrder(arrDNSServers) Next Set colNetCards = Nothing Set objWMIService = Nothing End Sub 'code ends Enjoy. Sincerely, Dèjì Akómöláfé, MCSE+M MCSA+M MCP+I Microsoft MVP - Directory Services www.readymaids.com - we know IT www.akomolafe.com Do you now realize that Today is the Tomorrow you were worried about Yesterday? -anon From: [EMAIL PROTECTED] on behalf of Tom Kern Sent: Sat 8/13/2005 4:41 PM To: ActiveDir@mail.activedir.org Subject: Re: [ActiveDir] ok, last one really what I really want to do, is modify that script to read all my servers with static ip's from a text file and change their dns ip's to point to 2 new dns servers and get rid of the old ones. we have about 500 servers and they all have static ip's and we're changing over our dns to 2 new servers. i'd like to script pointing them to the new servers. either remotely or from a login script. the script i sent will do that but you have to enter the server names/ip's in the script and it prints info to stdout. i'd rather it read from a text file and only log errors or info to a seperate file. is this doable? thanks a lot! On 8/12/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: How about While ts.AtEndOfStream strcomputer=ts.readline wend ts.close James R. Day Active Directory Core Team Office of the Chief Information Officer National Park Service 202-230-2983 [EMAIL PROTECTED] |-+-- | | Tom Kern | | | [EMAIL PROTECTED] | | | Sent by: | | | [EMAIL PROTECTED]| | | tivedir.org| | | | | | | | | 08/12/2005 04:32 PM AST| | | Please respond to | | | ActiveDir | |-+-- --| | | | To: ActiveDir@mail.activedir.org | | cc: (bcc: James Day/Contractor/NPS) | | Subject: Re: [ActiveDir] ok, last one really | --| how would you write that to loop thru every line in a file? thanks On 8/12/05, Alain Lissoir [EMAIL PROTECTED] wrote: On MSDN, you can find some sample scripts to read from a file. See at http://msdn.microsoft.com/library/en-us/script56/html/sgWorkingWithFiles.asp For instance, Dim fso, ts Const ForReading = 1 Set fso = CreateObject(Scripting. FileSystemObject) Set ts = fso.OpenTextFile(c:\test.txt, ForReading, True) strComputer = ts.ReadLine() ts.Close() Depending on the format of your file, you can read a single line and split the comma separated computer names or You can loop and read lines one-by-one if you have a computer name per line. Your call ... For a book on scripting and WMI, you can always have a look at my web site ;) http://www.lissware.net -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Kern Sent: Friday, August 12, 2005 7:46 AM To: activedirectory Subject
RE: [ActiveDir] ok, last one really
What, you mean you don't trust my codes? Shesh! :-p 'Still using the same folder structure and input file as before, you will run this AFTER running the previous script 'Code Begins Const FILEPATH = C:\MyScripts\ 'Get the input file Set FSO = CreateObject(Scripting.FileSystemObject) Set fsoFile = FSO.GetFile(FILEPATH Server-List.txt) strFilePath = fsoFile.Path Set fsoInput = FSO.OpenTextFile(strFilePath, 1) Set FSOWrite=FSO.OpenTextFile(FILEPATH Output.txt, 8, True) Do While Not fsoInput.AtEndOfStream ComputerName = fsoInput.ReadLine FSOWrite.WriteLine ComputerName Call ChangeDNS_addy(ComputerName) Loop FSOWrite.Close Set FSOWrite = Nothing Set fsoInput = Nothing Set fsoFile = Nothing set FSO=Nothing Sub ChangeDNS_addy(ComputerName) On Error Resume Next Set objWMIService = GetObject(winmgmts:\\ ComputerName \root\cimv2) Set colNetCards = objWMIService.ExecQuery _ (Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True) For Each objNetCard in colNetCards If Not IsNull(objNetCard.DNSServerSearchOrder) Then For i = 0 To UBound(objNetCard.DNSServerSearchOrder) FSOWrite.WriteLine vbTab objNetCard.DNSServerSearchOrder(i) Next End If Next Set colNetCards = Nothing Set objWMIService = Nothing End Sub 'Code Ends Sincerely, Dèjì Akómöláfé, MCSE+M MCSA+M MCP+I Microsoft MVP - Directory Services www.readymaids.com - we know IT www.akomolafe.com Do you now realize that Today is the Tomorrow you were worried about Yesterday? -anon From: [EMAIL PROTECTED] on behalf of Tom Kern Sent: Mon 8/15/2005 7:57 AM To: ActiveDir@mail.activedir.org Subject: Re: [ActiveDir] ok, last one really Now how can I write a script or modify that to tell me it worked? Do i need to write a new script to query the client dns ip's and feed it the same file and spit that out to a text file so i can see it took? thanks On 8/14/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Let's say the new DNS servers are 192.168.11.250 and 192.168.11.251 Let's say you have a folder called Myscripts in C:\ You create a file called Server-List.txt that contains all your servers' names, listed one per line and put it in C:\myscripts Then you copy the following code, put it in a file and call the file, say, change-dns.vbs Off you go. 'Code starts here Const FILEPATH = C:\MyScripts\ 'Get the input file Set FSO = CreateObject(Scripting.FileSystemObject) Set fsoFile = FSO.GetFile(FILEPATH Server-List.txt) strFilePath = fsoFile.Path Set fsoInput = FSO.OpenTextFile(strFilePath, 1) Do While Not fsoInput.AtEndOfStream ComputerName = fsoInput.ReadLine Call ChangeDNS_addy(ComputerName) Loop Set fsoInput = Nothing Set fsoFile = Nothing set FSO=Nothing Sub ChangeDNS_addy(ComputerName) On Error Resume Next Set objWMIService = GetObject(winmgmts:\\ ComputerName \root\cimv2) Set colNetCards = objWMIService.ExecQuery _ (Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True) For Each objNetCard in colNetCards arrDNSServers = Array(192.168.11.250, 192.168.11.251) objNetCard.SetDNSServerSearchOrder(arrDNSServers) Next Set colNetCards = Nothing Set objWMIService = Nothing End Sub 'code ends Enjoy. Sincerely, Dèjì Akómöláfé, MCSE+M MCSA+M MCP+I Microsoft MVP - Directory Services www.readymaids.com - we know IT www.akomolafe.com Do you now realize that Today is the Tomorrow you were worried about Yesterday? -anon From: [EMAIL PROTECTED] on behalf of Tom Kern Sent: Sat 8/13/2005 4:41 PM To: ActiveDir@mail.activedir.org Subject: Re: [ActiveDir] ok, last one really what I really want to do, is modify that script to read all my servers with static ip's from a text file and change their dns ip's to point to 2 new dns servers and get rid of the old ones. we have about 500 servers and they all have static ip's and we're changing over our dns to 2 new servers. i'd like to script pointing them to the new servers. either remotely or from a login script. the script i sent will do that but you have to enter the server names/ip's in the script and it prints info to stdout. i'd rather it read from a text file and only log errors or info to a seperate file. is this doable? thanks a lot! On 8/12/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: How about While ts.AtEndOfStream strcomputer=ts.readline wend ts.close James R. Day Active Directory Core Team Office of the Chief Information Officer National Park Service 202-230-2983 [EMAIL PROTECTED] |-+-- | | Tom Kern | | | [EMAIL PROTECTED] | | | Sent by: | | | [EMAIL PROTECTED]| | | tivedir.org
Re: [ActiveDir] ok, last one really
This script gives me the client dns ip's that are there as well as ones that haven't been there in a long time. one's i set and removed awhile ago. why is that? thanks On 8/15/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: What, you mean you don't trust my codes? Shesh! :-p 'Still using the same folder structure and input file as before, you will run this AFTER running the previous script 'Code Begins Const FILEPATH = C:\MyScripts\ 'Get the input file Set FSO = CreateObject(Scripting.FileSystemObject) Set fsoFile = FSO.GetFile(FILEPATH Server-List.txt) strFilePath = fsoFile.Path Set fsoInput = FSO.OpenTextFile(strFilePath, 1) Set FSOWrite=FSO.OpenTextFile(FILEPATH Output.txt, 8, True) Do While Not fsoInput.AtEndOfStream ComputerName = fsoInput.ReadLine FSOWrite.WriteLine ComputerName Call ChangeDNS_addy(ComputerName) Loop FSOWrite.Close Set FSOWrite = Nothing Set fsoInput = Nothing Set fsoFile = Nothing set FSO=Nothing Sub ChangeDNS_addy(ComputerName) On Error Resume Next Set objWMIService = GetObject(winmgmts:\\ ComputerName \root\cimv2) Set colNetCards = objWMIService.ExecQuery _ (Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True) For Each objNetCard in colNetCards If Not IsNull(objNetCard.DNSServerSearchOrder) Then For i = 0 To UBound(objNetCard.DNSServerSearchOrder) FSOWrite.WriteLine vbTab objNetCard.DNSServerSearchOrder(i) Next End If Next Set colNetCards = Nothing Set objWMIService = Nothing End Sub 'Code Ends Sincerely, Dèjì Akómöláfé, MCSE+M MCSA+M MCP+I Microsoft MVP - Directory Services www.readymaids.com - we know IT www.akomolafe.com Do you now realize that Today is the Tomorrow you were worried about Yesterday? -anon From: [EMAIL PROTECTED] on behalf of Tom Kern Sent: Mon 8/15/2005 7:57 AM To: ActiveDir@mail.activedir.org Subject: Re: [ActiveDir] ok, last one really Now how can I write a script or modify that to tell me it worked? Do i need to write a new script to query the client dns ip's and feed it the same file and spit that out to a text file so i can see it took? thanks On 8/14/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Let's say the new DNS servers are 192.168.11.250 and 192.168.11.251 Let's say you have a folder called Myscripts in C:\ You create a file called Server-List.txt that contains all your servers' names, listed one per line and put it in C:\myscripts Then you copy the following code, put it in a file and call the file, say, change-dns.vbs Off you go. 'Code starts here Const FILEPATH = C:\MyScripts\ 'Get the input file Set FSO = CreateObject(Scripting.FileSystemObject) Set fsoFile = FSO.GetFile(FILEPATH Server-List.txt) strFilePath = fsoFile.Path Set fsoInput = FSO.OpenTextFile(strFilePath, 1) Do While Not fsoInput.AtEndOfStream ComputerName = fsoInput.ReadLine Call ChangeDNS_addy(ComputerName) Loop Set fsoInput = Nothing Set fsoFile = Nothing set FSO=Nothing Sub ChangeDNS_addy(ComputerName) On Error Resume Next Set objWMIService = GetObject(winmgmts:\\ ComputerName \root\cimv2) Set colNetCards = objWMIService.ExecQuery _ (Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True) For Each objNetCard in colNetCards arrDNSServers = Array(192.168.11.250, 192.168.11.251) objNetCard.SetDNSServerSearchOrder(arrDNSServers) Next Set colNetCards = Nothing Set objWMIService = Nothing End Sub 'code ends Enjoy. Sincerely, Dèjì Akómöláfé, MCSE+M MCSA+M MCP+I Microsoft MVP - Directory Services www.readymaids.com - we know IT www.akomolafe.com Do you now realize that Today is the Tomorrow you were worried about Yesterday? -anon From: [EMAIL PROTECTED] on behalf of Tom Kern Sent: Sat 8/13/2005 4:41 PM To: ActiveDir@mail.activedir.org Subject: Re: [ActiveDir] ok, last one really what I really want to do, is modify that script to read all my servers with static ip's from a text file and change their dns ip's to point to 2 new dns servers and get rid of the old ones. we have about 500 servers and they all have static ip's and we're changing over our dns to 2 new servers. i'd like to script pointing them to the new servers. either remotely or from a login script. the script i sent will do that but you have to enter the server names/ip's in the script and it prints info to stdout. i'd rather it read from a text file and only log errors or info to a seperate file. is this doable? thanks a lot! On 8/12/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: How about While ts.AtEndOfStream strcomputer=ts.readline wend ts.close James R. Day Active Directory Core Team Office of the Chief Information Officer National Park Service 202-230-2983 [EMAIL PROTECTED
RE: [ActiveDir] ok, last one really
probably because those addresses are still in the registry and have not been whacked. Sincerely, Dèjì Akómöláfé, MCSE+M MCSA+M MCP+I Microsoft MVP - Directory Services www.readymaids.com - we know IT www.akomolafe.com Do you now realize that Today is the Tomorrow you were worried about Yesterday? -anon From: [EMAIL PROTECTED] on behalf of Tom Kern Sent: Mon 8/15/2005 12:11 PM To: ActiveDir@mail.activedir.org Subject: Re: [ActiveDir] ok, last one really This script gives me the client dns ip's that are there as well as ones that haven't been there in a long time. one's i set and removed awhile ago. why is that? thanks On 8/15/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: What, you mean you don't trust my codes? Shesh! :-p 'Still using the same folder structure and input file as before, you will run this AFTER running the previous script 'Code Begins Const FILEPATH = C:\MyScripts\ 'Get the input file Set FSO = CreateObject(Scripting.FileSystemObject) Set fsoFile = FSO.GetFile(FILEPATH Server-List.txt) strFilePath = fsoFile.Path Set fsoInput = FSO.OpenTextFile(strFilePath, 1) Set FSOWrite=FSO.OpenTextFile(FILEPATH Output.txt, 8, True) Do While Not fsoInput.AtEndOfStream ComputerName = fsoInput.ReadLine FSOWrite.WriteLine ComputerName Call ChangeDNS_addy(ComputerName) Loop FSOWrite.Close Set FSOWrite = Nothing Set fsoInput = Nothing Set fsoFile = Nothing set FSO=Nothing Sub ChangeDNS_addy(ComputerName) On Error Resume Next Set objWMIService = GetObject(winmgmts:\\ ComputerName \root\cimv2) Set colNetCards = objWMIService.ExecQuery _ (Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True) For Each objNetCard in colNetCards If Not IsNull(objNetCard.DNSServerSearchOrder) Then For i = 0 To UBound(objNetCard.DNSServerSearchOrder) FSOWrite.WriteLine vbTab objNetCard.DNSServerSearchOrder(i) Next End If Next Set colNetCards = Nothing Set objWMIService = Nothing End Sub 'Code Ends Sincerely, Dèjì Akómöláfé, MCSE+M MCSA+M MCP+I Microsoft MVP - Directory Services www.readymaids.com - we know IT www.akomolafe.com Do you now realize that Today is the Tomorrow you were worried about Yesterday? -anon From: [EMAIL PROTECTED] on behalf of Tom Kern Sent: Mon 8/15/2005 7:57 AM To: ActiveDir@mail.activedir.org Subject: Re: [ActiveDir] ok, last one really Now how can I write a script or modify that to tell me it worked? Do i need to write a new script to query the client dns ip's and feed it the same file and spit that out to a text file so i can see it took? thanks On 8/14/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Let's say the new DNS servers are 192.168.11.250 and 192.168.11.251 Let's say you have a folder called Myscripts in C:\ You create a file called Server-List.txt that contains all your servers' names, listed one per line and put it in C:\myscripts Then you copy the following code, put it in a file and call the file, say, change-dns.vbs Off you go. 'Code starts here Const FILEPATH = C:\MyScripts\ 'Get the input file Set FSO = CreateObject(Scripting.FileSystemObject) Set fsoFile = FSO.GetFile(FILEPATH Server-List.txt) strFilePath = fsoFile.Path Set fsoInput = FSO.OpenTextFile(strFilePath, 1) Do While Not fsoInput.AtEndOfStream ComputerName = fsoInput.ReadLine Call ChangeDNS_addy(ComputerName) Loop Set fsoInput = Nothing Set fsoFile = Nothing set FSO=Nothing Sub ChangeDNS_addy(ComputerName) On Error Resume Next Set objWMIService = GetObject(winmgmts:\\ ComputerName \root\cimv2) Set colNetCards = objWMIService.ExecQuery _ (Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True) For Each objNetCard in colNetCards arrDNSServers = Array(192.168.11.250, 192.168.11.251) objNetCard.SetDNSServerSearchOrder(arrDNSServers) Next Set colNetCards = Nothing Set objWMIService = Nothing End Sub 'code ends Enjoy. Sincerely, Dèjì Akómöláfé, MCSE+M MCSA+M MCP+I Microsoft MVP - Directory Services www.readymaids.com - we know IT www.akomolafe.com Do you now realize that Today is the Tomorrow you were worried about Yesterday? -anon From: [EMAIL PROTECTED] on behalf of Tom Kern Sent: Sat 8/13/2005 4:41 PM To: ActiveDir@mail.activedir.org Subject: Re: [ActiveDir] ok, last one really what I really want to do, is modify that script to read all my servers with static ip's from a text file and change their dns ip's to point to 2 new dns servers and get rid of the old ones. we have about 500 servers and they all have static ip's and we're changing over our dns to 2 new servers. i'd like to script pointing them to the new servers. either remotely or from a login script. the script i sent will do that but you have to enter the server names/ip's
Re: [ActiveDir] ok, last one really
So, if i set a dns addy and then change it or use dhcp to set it, windows will still keep a phantom reference to it in the registry? is there a normal procedure to whack it? On 8/15/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: probably because those addresses are still in the registry and have not been whacked. Sincerely, Dèjì Akómöláfé, MCSE+M MCSA+M MCP+I Microsoft MVP - Directory Services www.readymaids.com - we know IT www.akomolafe.com Do you now realize that Today is the Tomorrow you were worried about Yesterday? -anon From: [EMAIL PROTECTED] on behalf of Tom Kern Sent: Mon 8/15/2005 12:11 PM To: ActiveDir@mail.activedir.org Subject: Re: [ActiveDir] ok, last one really This script gives me the client dns ip's that are there as well as ones that haven't been there in a long time. one's i set and removed awhile ago. why is that? thanks On 8/15/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: What, you mean you don't trust my codes? Shesh! :-p 'Still using the same folder structure and input file as before, you will run this AFTER running the previous script 'Code Begins Const FILEPATH = C:\MyScripts\ 'Get the input file Set FSO = CreateObject(Scripting.FileSystemObject) Set fsoFile = FSO.GetFile(FILEPATH Server-List.txt) strFilePath = fsoFile.Path Set fsoInput = FSO.OpenTextFile(strFilePath, 1) Set FSOWrite=FSO.OpenTextFile(FILEPATH Output.txt, 8, True) Do While Not fsoInput.AtEndOfStream ComputerName = fsoInput.ReadLine FSOWrite.WriteLine ComputerName Call ChangeDNS_addy(ComputerName) Loop FSOWrite.Close Set FSOWrite = Nothing Set fsoInput = Nothing Set fsoFile = Nothing set FSO=Nothing Sub ChangeDNS_addy(ComputerName) On Error Resume Next Set objWMIService = GetObject(winmgmts:\\ ComputerName \root\cimv2) Set colNetCards = objWMIService.ExecQuery _ (Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True) For Each objNetCard in colNetCards If Not IsNull(objNetCard.DNSServerSearchOrder) Then For i = 0 To UBound(objNetCard.DNSServerSearchOrder) FSOWrite.WriteLine vbTab objNetCard.DNSServerSearchOrder(i) Next End If Next Set colNetCards = Nothing Set objWMIService = Nothing End Sub 'Code Ends Sincerely, Dèjì Akómöláfé, MCSE+M MCSA+M MCP+I Microsoft MVP - Directory Services www.readymaids.com - we know IT www.akomolafe.com Do you now realize that Today is the Tomorrow you were worried about Yesterday? -anon From: [EMAIL PROTECTED] on behalf of Tom Kern Sent: Mon 8/15/2005 7:57 AM To: ActiveDir@mail.activedir.org Subject: Re: [ActiveDir] ok, last one really Now how can I write a script or modify that to tell me it worked? Do i need to write a new script to query the client dns ip's and feed it the same file and spit that out to a text file so i can see it took? thanks On 8/14/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Let's say the new DNS servers are 192.168.11.250 and 192.168.11.251 Let's say you have a folder called Myscripts in C:\ You create a file called Server-List.txt that contains all your servers' names, listed one per line and put it in C:\myscripts Then you copy the following code, put it in a file and call the file, say, change-dns.vbs Off you go. 'Code starts here Const FILEPATH = C:\MyScripts\ 'Get the input file Set FSO = CreateObject(Scripting.FileSystemObject) Set fsoFile = FSO.GetFile(FILEPATH Server-List.txt) strFilePath = fsoFile.Path Set fsoInput = FSO.OpenTextFile(strFilePath, 1) Do While Not fsoInput.AtEndOfStream ComputerName = fsoInput.ReadLine Call ChangeDNS_addy(ComputerName) Loop Set fsoInput = Nothing Set fsoFile = Nothing set FSO=Nothing Sub ChangeDNS_addy(ComputerName) On Error Resume Next Set objWMIService = GetObject(winmgmts:\\ ComputerName \root\cimv2) Set colNetCards = objWMIService.ExecQuery _ (Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True) For Each objNetCard in colNetCards arrDNSServers = Array(192.168.11.250, 192.168.11.251) objNetCard.SetDNSServerSearchOrder(arrDNSServers) Next Set colNetCards = Nothing Set objWMIService = Nothing End Sub 'code ends Enjoy. Sincerely, Dèjì Akómöláfé, MCSE+M MCSA+M MCP+I Microsoft MVP - Directory Services www.readymaids.com - we know IT www.akomolafe.com Do you now realize that Today is the Tomorrow you were worried about Yesterday? -anon From: [EMAIL PROTECTED] on behalf of Tom Kern Sent: Sat 8/13/2005 4:41 PM To: ActiveDir@mail.activedir.org Subject: Re: [ActiveDir] ok, last one really what I really want to do, is modify that script to read all my servers with static
Re: [ActiveDir] ok, last one really
what I really want to do, is modify that script to read all my servers with static ip's from a text file and change their dns ip's to point to 2 new dns servers and get rid of the old ones. we have about 500 servers and they all have static ip's and we're changing over our dns to 2 new servers. i'd like to script pointing them to the new servers. either remotely or from a login script. the script i sent will do that but you have to enter the server names/ip's in the script and it prints info to stdout. i'd rather it read from a text file and only log errors or info to a seperate file. is this doable? thanks a lot! On 8/12/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: How about While ts.AtEndOfStream strcomputer=ts.readline wend ts.close James R. Day Active Directory Core Team Office of the Chief Information Officer National Park Service 202-230-2983 [EMAIL PROTECTED] |-+-- | | Tom Kern | | | [EMAIL PROTECTED] | | | Sent by: | | | [EMAIL PROTECTED]| | | tivedir.org| | | | | | | | | 08/12/2005 04:32 PM AST| | | Please respond to | | | ActiveDir | |-+-- --| | | | To: ActiveDir@mail.activedir.org | | cc: (bcc: James Day/Contractor/NPS) | | Subject: Re: [ActiveDir] ok, last one really | --| how would you write that to loop thru every line in a file? thanks On 8/12/05, Alain Lissoir [EMAIL PROTECTED] wrote: On MSDN, you can find some sample scripts to read from a file. See at http://msdn.microsoft.com/library/en-us/script56/html/sgWorkingWithFiles.asp For instance, Dim fso, ts Const ForReading = 1 Set fso = CreateObject(Scripting. FileSystemObject) Set ts = fso.OpenTextFile(c:\test.txt, ForReading, True) strComputer = ts.ReadLine() ts.Close() Depending on the format of your file, you can read a single line and split the comma separated computer names or You can loop and read lines one-by-one if you have a computer name per line. Your call ... For a book on scripting and WMI, you can always have a look at my web site ;) http://www.lissware.net -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Kern Sent: Friday, August 12, 2005 7:46 AM To: activedirectory Subject: [ActiveDir] ok, last one really How can i change this script so i can just feed it a file of computer names so i can automate the changing of dns servers in the client properties? SCRIPT- On Error Resume Next strComputer = . arrNewDNSServerSearchOrder = Array(192.168.0.1, 192.168.0.2) Set objWMIService = GetObject(winmgmts: _ {impersonationLevel=impersonate}!\\ strComputer \root\cimv2) Set colNicConfigs = objWMIService.ExecQuery _ (SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True) WScript.Echo VbCrLf Computer: strComputer For Each objNicConfig In colNicConfigs WScript.Echo VbCrLfNetwork Adapter objNicConfig.Index WScript.Echo DNS Server Search Order - Before: If Not IsNull(objNicConfig.DNSServerSearchOrder) Then For Each strDNSServer In objNicConfig.DNSServerSearchOrder WScript.Echo strDNSServer Next End If intSetDNSServers = _ objNicConfig.SetDNSServerSearchOrder(arrNewDNSServerSearchOrder) If intSetDNSServers = 0 Then WScript.Echo Replaced DNS server search order list. Else WScript.Echo Unable to replace DNS server search order list. End If Next WScript.Echo VbCrLf String(80, -) Set colNicConfigs = objWMIService.ExecQuery _ (SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True) For Each objNicConfig In colNicConfigs WScript.Echo VbCrLfNetwork Adapter objNicConfig.Index WScript.Echo DNS Server Search Order - After: If Not IsNull(objNicConfig.DNSServerSearchOrder) Then For Each strDNSServer In objNicConfig.DNSServerSearchOrder WScript.Echo strDNSServer Next End
RE: [ActiveDir] ok, last one really
Title: RE: [ActiveDir] ok, last one really How do you setup folder redirection? How does it work? 1. create shared folder 2. start, programs, administrative tools, AD Users Computers 3. OU right click, properties, Group policy 4. new, any name, click name, edit, user config, windows settings 5. folder redirection, my docs Where do you go from here? Thanks all -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Tom Kern Sent: Saturday, August 13, 2005 4:41 PM To: ActiveDir@mail.activedir.org Subject: Re: [ActiveDir] ok, last one really what I really want to do, is modify that script to read all my servers with static ip's from a text file and change their dns ip's to point to 2 new dns servers and get rid of the old ones. we have about 500 servers and they all have static ip's and we're changing over our dns to 2 new servers. i'd like to script pointing them to the new servers. either remotely or from a login script. the script i sent will do that but you have to enter the server names/ip's in the script and it prints info to stdout. i'd rather it read from a text file and only log errors or info to a seperate file. is this doable? thanks a lot! On 8/12/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: How about While ts.AtEndOfStream strcomputer=ts.readline wend ts.close James R. Day Active Directory Core Team Office of the Chief Information Officer National Park Service 202-230-2983 [EMAIL PROTECTED] |-+-- | | Tom Kern | | | [EMAIL PROTECTED] | | | Sent by: | | | [EMAIL PROTECTED]| | | tivedir.org | | | | | | | | | 08/12/2005 04:32 PM AST| | | Please respond to | | | ActiveDir | |-+-- --| | | | To: ActiveDir@mail.activedir.org | | cc: (bcc: James Day/Contractor/NPS) | | Subject: Re: [ActiveDir] ok, last one really | --| how would you write that to loop thru every line in a file? thanks On 8/12/05, Alain Lissoir [EMAIL PROTECTED] wrote: On MSDN, you can find some sample scripts to read from a file. See at http://msdn.microsoft.com/library/en-us/script56/html/sgWorkingWithFiles.asp For instance, Dim fso, ts Const ForReading = 1 Set fso = CreateObject(Scripting. FileSystemObject) Set ts = fso.OpenTextFile(c:\test.txt, ForReading, True) strComputer = ts.ReadLine() ts.Close() Depending on the format of your file, you can read a single line and split the comma separated computer names or You can loop and read lines one-by-one if you have a computer name per line. Your call ... For a book on scripting and WMI, you can always have a look at my web site ;) http://www.lissware.net -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Tom Kern Sent: Friday, August 12, 2005 7:46 AM To: activedirectory Subject: [ActiveDir] ok, last one really How can i change this script so i can just feed it a file of computer names so i can automate the changing of dns servers in the client properties? SCRIPT- On Error Resume Next strComputer = . arrNewDNSServerSearchOrder = Array(192.168.0.1, 192.168.0.2) Set objWMIService = GetObject(winmgmts: _ {impersonationLevel=impersonate}!\\ strComputer \root\cimv2) Set colNicConfigs = objWMIService.ExecQuery _ (SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True) WScript.Echo VbCrLf Computer: strComputer For Each objNicConfig In colNicConfigs WScript.Echo VbCrLf Network Adapter objNicConfig.Index WScript.Echo DNS Server Search Order - Before: If Not IsNull(objNicConfig.DNSServerSearchOrder) Then For Each strDNSServer In objNicConfig.DNSServerSearchOrder WScript.EchostrDNSServer Next End If intSetDNSServers = _ objNicConfig.SetDNSServerSearchOrder(arrNewDNSServerSearchOrder) If intSetDNSServers = 0 Then WScript.Echo Replaced DNS server search order list. Else WScript.Echo Unable to replace DNS server search order list. End If Next WScript.Echo VbCrLf String(80, -) Set colNicConfigs = objWMIService.ExecQuery _ (SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True) For Each objNicConfig In colNicConfigs WScript.Echo VbCrLf Network Adapter objNicConfig.Index WScript.Echo DNS Server Search Order - After: If Not IsNull(objNicConfig.DNSServerSearchOrder) Then For Each strDNSServer In objNicConfig.DNSServerSearchOrder WScript.EchostrDNSServer Next End If Next END OF SCRIPT
RE: [ActiveDir] ok, last one really
I'm certain this can be done Tom...I'm in a hurry at the moment so I can't do the research...but you may want to use your favorite search engine (for instance, MSN Search) and look for the following: text file input and vbs That may give you enough to go on and find what you wish to do. I'm 100% certain this can work though as I've done it before. I just don't have that script handy at the moment (reference 'the hurry'). If you can't find it, please repost (or reply to me) and I'll find something. Look and Ye shall find!! Robert Williams, MCSE NT4/2K/2K3, Security+ Infrastructure Rapid Response Engineer Northeast Region Microsoft Corporation Global Solutions Support Center -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Kern Sent: Saturday, August 13, 2005 7:41 PM To: ActiveDir@mail.activedir.org Subject: Re: [ActiveDir] ok, last one really what I really want to do, is modify that script to read all my servers with static ip's from a text file and change their dns ip's to point to 2 new dns servers and get rid of the old ones. we have about 500 servers and they all have static ip's and we're changing over our dns to 2 new servers. i'd like to script pointing them to the new servers. either remotely or from a login script. the script i sent will do that but you have to enter the server names/ip's in the script and it prints info to stdout. i'd rather it read from a text file and only log errors or info to a seperate file. is this doable? thanks a lot! On 8/12/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: How about While ts.AtEndOfStream strcomputer=ts.readline wend ts.close James R. Day Active Directory Core Team Office of the Chief Information Officer National Park Service 202-230-2983 [EMAIL PROTECTED] |-+-- | | Tom Kern | | | [EMAIL PROTECTED] | | | Sent by: | | | [EMAIL PROTECTED]| | | tivedir.org| | | | | | | | | 08/12/2005 04:32 PM AST| | | Please respond to | | | ActiveDir | |-+-- --- ---| | | | To: ActiveDir@mail.activedir.org | | cc: (bcc: James Day/Contractor/NPS) | | Subject: Re: [ActiveDir] ok, last one really | --- ---| how would you write that to loop thru every line in a file? thanks On 8/12/05, Alain Lissoir [EMAIL PROTECTED] wrote: On MSDN, you can find some sample scripts to read from a file. See at http://msdn.microsoft.com/library/en-us/script56/html/sgWorkingWithFiles .asp For instance, Dim fso, ts Const ForReading = 1 Set fso = CreateObject(Scripting. FileSystemObject) Set ts = fso.OpenTextFile(c:\test.txt, ForReading, True) strComputer = ts.ReadLine() ts.Close() Depending on the format of your file, you can read a single line and split the comma separated computer names or You can loop and read lines one-by-one if you have a computer name per line. Your call ... For a book on scripting and WMI, you can always have a look at my web site ;) http://www.lissware.net -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Kern Sent: Friday, August 12, 2005 7:46 AM To: activedirectory Subject: [ActiveDir] ok, last one really How can i change this script so i can just feed it a file of computer names so i can automate the changing of dns servers in the client properties? SCRIPT- On Error Resume Next strComputer = . arrNewDNSServerSearchOrder = Array(192.168.0.1, 192.168.0.2) Set objWMIService = GetObject(winmgmts: _ {impersonationLevel=impersonate}!\\ strComputer \root\cimv2) Set colNicConfigs = objWMIService.ExecQuery _ (SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True) WScript.Echo VbCrLf Computer: strComputer For Each objNicConfig In colNicConfigs WScript.Echo VbCrLfNetwork Adapter objNicConfig.Index WScript.Echo DNS Server Search Order - Before: If Not IsNull(objNicConfig.DNSServerSearchOrder) Then For Each strDNSServer In objNicConfig.DNSServerSearchOrder WScript.Echo strDNSServer Next End If intSetDNSServers = _ objNicConfig.SetDNSServerSearchOrder(arrNewDNSServerSearchOrder) If intSetDNSServers = 0 Then WScript.Echo Replaced DNS server search order list. Else WScript.Echo Unable to replace DNS server
RE: [ActiveDir] ok, last one really
Let's say the new DNS servers are 192.168.11.250 and 192.168.11.251 Let's say you have a folder called Myscripts in C:\ You create a file called Server-List.txt that contains all your servers' names, listed one per line and put it in C:\myscripts Then you copy the following code, put it in a file and call the file, say, change-dns.vbs Off you go. 'Code starts here Const FILEPATH = C:\MyScripts\ 'Get the input file Set FSO = CreateObject(Scripting.FileSystemObject) Set fsoFile = FSO.GetFile(FILEPATH Server-List.txt) strFilePath = fsoFile.Path Set fsoInput = FSO.OpenTextFile(strFilePath, 1) Do While Not fsoInput.AtEndOfStream ComputerName = fsoInput.ReadLine Call ChangeDNS_addy(ComputerName) Loop Set fsoInput = Nothing Set fsoFile = Nothing set FSO=Nothing Sub ChangeDNS_addy(ComputerName) On Error Resume Next Set objWMIService = GetObject(winmgmts:\\ ComputerName \root\cimv2) Set colNetCards = objWMIService.ExecQuery _ (Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True) For Each objNetCard in colNetCards arrDNSServers = Array(192.168.11.250, 192.168.11.251) objNetCard.SetDNSServerSearchOrder(arrDNSServers) Next Set colNetCards = Nothing Set objWMIService = Nothing End Sub 'code ends Enjoy. Sincerely, Dèjì Akómöláfé, MCSE+M MCSA+M MCP+I Microsoft MVP - Directory Services www.readymaids.com - we know IT www.akomolafe.com Do you now realize that Today is the Tomorrow you were worried about Yesterday? -anon From: [EMAIL PROTECTED] on behalf of Tom Kern Sent: Sat 8/13/2005 4:41 PM To: ActiveDir@mail.activedir.org Subject: Re: [ActiveDir] ok, last one really what I really want to do, is modify that script to read all my servers with static ip's from a text file and change their dns ip's to point to 2 new dns servers and get rid of the old ones. we have about 500 servers and they all have static ip's and we're changing over our dns to 2 new servers. i'd like to script pointing them to the new servers. either remotely or from a login script. the script i sent will do that but you have to enter the server names/ip's in the script and it prints info to stdout. i'd rather it read from a text file and only log errors or info to a seperate file. is this doable? thanks a lot! On 8/12/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: How about While ts.AtEndOfStream strcomputer=ts.readline wend ts.close James R. Day Active Directory Core Team Office of the Chief Information Officer National Park Service 202-230-2983 [EMAIL PROTECTED] |-+-- | | Tom Kern | | | [EMAIL PROTECTED] | | | Sent by: | | | [EMAIL PROTECTED]| | | tivedir.org| | | | | | | | | 08/12/2005 04:32 PM AST| | | Please respond to | | | ActiveDir | |-+-- --| | | | To: ActiveDir@mail.activedir.org | | cc: (bcc: James Day/Contractor/NPS) | | Subject: Re: [ActiveDir] ok, last one really | --| how would you write that to loop thru every line in a file? thanks On 8/12/05, Alain Lissoir [EMAIL PROTECTED] wrote: On MSDN, you can find some sample scripts to read from a file. See at http://msdn.microsoft.com/library/en-us/script56/html/sgWorkingWithFiles.asp For instance, Dim fso, ts Const ForReading = 1 Set fso = CreateObject(Scripting. FileSystemObject) Set ts = fso.OpenTextFile(c:\test.txt, ForReading, True) strComputer = ts.ReadLine() ts.Close() Depending on the format of your file, you can read a single line and split the comma separated computer names or You can loop and read lines one-by-one if you have a computer name per line. Your call ... For a book on scripting and WMI, you can always have a look at my web site ;) http://www.lissware.net -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Kern Sent: Friday, August 12, 2005 7:46 AM To: activedirectory Subject: [ActiveDir] ok, last one really How can i change this script so i can just feed it a file of computer names so i can automate the changing of dns servers in the client properties? SCRIPT- On Error Resume Next strComputer = . arrNewDNSServerSearchOrder = Array(192.168.0.1, 192.168.0.2) Set objWMIService = GetObject(winmgmts: _ {impersonationLevel=impersonate}!\\ strComputer \root\cimv2) Set
RE: [ActiveDir] ok, last one really
As WMI goes, these are the best books available - period. Rick -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alain Lissoir Sent: Friday, August 12, 2005 10:40 AM To: ActiveDir@mail.activedir.org Subject: RE: [ActiveDir] ok, last one really On MSDN, you can find some sample scripts to read from a file. See at http://msdn.microsoft.com/library/en-us/script56/html/sgWorkingWithFiles.asp For instance, Dim fso, ts Const ForReading = 1 Set fso = CreateObject(Scripting. FileSystemObject) Set ts = fso.OpenTextFile(c:\test.txt, ForReading, True) strComputer = ts.ReadLine() ts.Close() Depending on the format of your file, you can read a single line and split the comma separated computer names or You can loop and read lines one-by-one if you have a computer name per line. Your call ... For a book on scripting and WMI, you can always have a look at my web site ;) http://www.lissware.net -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Kern Sent: Friday, August 12, 2005 7:46 AM To: activedirectory Subject: [ActiveDir] ok, last one really How can i change this script so i can just feed it a file of computer names so i can automate the changing of dns servers in the client properties? SCRIPT- On Error Resume Next strComputer = . arrNewDNSServerSearchOrder = Array(192.168.0.1, 192.168.0.2) Set objWMIService = GetObject(winmgmts: _ {impersonationLevel=impersonate}!\\ strComputer \root\cimv2) Set colNicConfigs = objWMIService.ExecQuery _ (SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True) WScript.Echo VbCrLf Computer: strComputer For Each objNicConfig In colNicConfigs WScript.Echo VbCrLfNetwork Adapter objNicConfig.Index WScript.Echo DNS Server Search Order - Before: If Not IsNull(objNicConfig.DNSServerSearchOrder) Then For Each strDNSServer In objNicConfig.DNSServerSearchOrder WScript.Echo strDNSServer Next End If intSetDNSServers = _ objNicConfig.SetDNSServerSearchOrder(arrNewDNSServerSearchOrder) If intSetDNSServers = 0 Then WScript.Echo Replaced DNS server search order list. Else WScript.Echo Unable to replace DNS server search order list. End If Next WScript.Echo VbCrLf String(80, -) Set colNicConfigs = objWMIService.ExecQuery _ (SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True) For Each objNicConfig In colNicConfigs WScript.Echo VbCrLfNetwork Adapter objNicConfig.Index WScript.Echo DNS Server Search Order - After: If Not IsNull(objNicConfig.DNSServerSearchOrder) Then For Each strDNSServer In objNicConfig.DNSServerSearchOrder WScript.Echo strDNSServer Next End If Next END OF SCRIPT also, can anyone recommend a good VBscript book for Windows admining so i can leave you guys alone? thanks List info : http://www.activedir.org/List.aspx List FAQ: http://www.activedir.org/ListFAQ.aspx List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/ List info : http://www.activedir.org/List.aspx List FAQ: http://www.activedir.org/ListFAQ.aspx List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/ List info : http://www.activedir.org/List.aspx List FAQ: http://www.activedir.org/ListFAQ.aspx List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/
RE: [ActiveDir] ok, last one really
Watch for line wraps; you'll want to put your code between a While/Wend loop. Dim fso, ts Const ForReading = 1 Set fso = CreateObject(Scripting. FileSystemObject) Set ts = fso.OpenTextFile(c:\test.txt, ForReading, True) While NOT ts.AtEndOfStream strComputer = ts.ReadLine() rest of your code goes here Wend ts.Close() -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Kern Sent: Friday, August 12, 2005 2:32 PM To: ActiveDir@mail.activedir.org Subject: Re: [ActiveDir] ok, last one really how would you write that to loop thru every line in a file? thanks On 8/12/05, Alain Lissoir [EMAIL PROTECTED] wrote: On MSDN, you can find some sample scripts to read from a file. See at http://msdn.microsoft.com/library/en-us/script56/html/sgWorkingWithFil es.asp For instance, Dim fso, ts Const ForReading = 1 Set fso = CreateObject(Scripting. FileSystemObject) Set ts = fso.OpenTextFile(c:\test.txt, ForReading, True) strComputer = ts.ReadLine() ts.Close() Depending on the format of your file, you can read a single line and split the comma separated computer names or You can loop and read lines one-by-one if you have a computer name per line. Your call ... For a book on scripting and WMI, you can always have a look at my web site ;) http://www.lissware.net -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Kern Sent: Friday, August 12, 2005 7:46 AM To: activedirectory Subject: [ActiveDir] ok, last one really How can i change this script so i can just feed it a file of computer names so i can automate the changing of dns servers in the client properties? SCRIPT- On Error Resume Next strComputer = . arrNewDNSServerSearchOrder = Array(192.168.0.1, 192.168.0.2) Set objWMIService = GetObject(winmgmts: _ {impersonationLevel=impersonate}!\\ strComputer \root\cimv2) Set colNicConfigs = objWMIService.ExecQuery _ (SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True) WScript.Echo VbCrLf Computer: strComputer For Each objNicConfig In colNicConfigs WScript.Echo VbCrLf Network Adapter objNicConfig.Index WScript.Echo DNS Server Search Order - Before: If Not IsNull(objNicConfig.DNSServerSearchOrder) Then For Each strDNSServer In objNicConfig.DNSServerSearchOrder WScript.Echo strDNSServer Next End If intSetDNSServers = _ objNicConfig.SetDNSServerSearchOrder(arrNewDNSServerSearchOrder) If intSetDNSServers = 0 Then WScript.Echo Replaced DNS server search order list. Else WScript.Echo Unable to replace DNS server search order list. End If Next WScript.Echo VbCrLf String(80, -) Set colNicConfigs = objWMIService.ExecQuery _ (SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True) For Each objNicConfig In colNicConfigs WScript.Echo VbCrLf Network Adapter objNicConfig.Index WScript.Echo DNS Server Search Order - After: If Not IsNull(objNicConfig.DNSServerSearchOrder) Then For Each strDNSServer In objNicConfig.DNSServerSearchOrder WScript.Echo strDNSServer Next End If Next END OF SCRIPT also, can anyone recommend a good VBscript book for Windows admining so i can leave you guys alone? thanks List info : http://www.activedir.org/List.aspx List FAQ: http://www.activedir.org/ListFAQ.aspx List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/ List info : http://www.activedir.org/List.aspx List FAQ: http://www.activedir.org/ListFAQ.aspx List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/ List info : http://www.activedir.org/List.aspx List FAQ: http://www.activedir.org/ListFAQ.aspx List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/ List info : http://www.activedir.org/List.aspx List FAQ: http://www.activedir.org/ListFAQ.aspx List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/