- notageek.it di Mirko Iodice - http://www.notageek.it -
Read Computer Names From Text File With Error Handling
Posted By Mirko On 13 giugno 2007 @ 12:15 In Scripts | No Comments
Questo lo definirei un "Wrapper Script", la sua funzione è quella di "avvolgere" quel codice sorgente che era stato realizzato per il semplice uso locale ed aggiungervi le funzionalità che permettono di eseguirlo su una serie di computer specificati in un elenco.
Per utilizzarlo è necessario specificare una stringa di connessione sotto alla riga '***MAKE CONNECTION*** ed inserire il codice da eseguire nella sezione '***REST OF CODE HERE***.
I dettagli relativi agli errori di connessione vengono scritti in un file di testo denominato "errors.txt".
E' possibile generare velocemente l'elenco di computer da fornire come input utilizzando lo script “List All Computers And Users Within An OU And SubOUs [1]“.
Per un esempio di come possa essere implementato questo wrapper consultare il codice di entrambe le versioni dello script Remote IPConfig [2].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 'Create a FileSystemObject Set oFS = CreateObject("Scripting.FileSystemObject") 'Open a text file of computer names 'with one computer name per line Set oTS = oFS.OpenTextFile("computers.txt") Set oTSOut = oFS.CreateTextFile("errors.txt") 'go through the text file Do Until oTS.AtEndOfStream 'get next computer sComputer = oTS.ReadLine On Error Resume Next '***MAKE CONNECTION*** If Err <> 0 Then oTSOut.WriteLine "Error on " & sComputer & ":" & Err.Number & ", " & Err.Description Else On Error Goto 0 '***REST OF CODE HERE*** End If Loop oTS.Close oTSOut.Close |
Article printed from notageek.it di Mirko Iodice: http://www.notageek.it
URL to article: http://www.notageek.it/read-computer-names-from-text-file-with-error-handling.html
URLs in this post:
[1] List All Computers And Users Within An OU And SubOUs: http://www.notageek.it/list-all-computers-and-users-within-an-ou-and-subous.html
[2] Remote IPConfig: http://www.notageek.it/remote-ipconfig.html
[3] read_computer_names_from_text_file_with_error_handling.zip: http://www.notageek.it/wp-includes/files/read_computer_names_from_text_file_with_error_handling.zip
Click here to print.
Copyright © 2009 notageek.it. All rights reserved.