Re: Input File for Script

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Scott" <Scott@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:96EADDFE-6F54-4CE6-9277-16E39BEF07A4@xxxxxxxxxxxxxxxx
>I have found the below script online (Thanks Alex and Torgeir) that does
> everything I need to do when searching for members of the local
> administrators group. I would like to know if someone can tell me how to
> use
> an input file to populate the aComputers field. I have a file
> (computers.txt) that has all of the computers listed that I would like to
> search. How can I make this script use this standard text file to input
> the
> array of computers?

The seven lines below should do this for you, assuming that your text file
has one computer name per line with no extraneous characters or whitespace.
Alternatively, if these are members of an active directory domain, perhaps a
better approach would be to get the computer names from there.

> ' some array with computers
> aComputers = Array("computer1", "computer2")

const ForReading = 1
set fso = createobject("scripting.filesystemobject")
set fileob = fso.opentextfile("C:\computers.txt",forReading,true
filecontent = fileob.readall
fileob.close
set fileob = nothing
aComputers = split(filecontent,vbnewline)

/Al

> For Each sComputer In aComputers
> ' check if computer is online
> If IsConnectible(sComputer, 1, 750) Then
>
>
> ' suppress errors
> On Error Resume Next
>
>
> ' group name to list users from
> Set oGroupAdm = GetObject("WinNT://" & sComputer & "/Administrators")
> If Err.Number = 0 Then
> WScript.Echo "Administator members of computer: " & sComputer &
> vbCrLf
> ' loop through all member of the group
> For Each oAdmGrpUser In oGroupAdm.Members
> ' get the name
> sAdmGrpUser = oAdmGrpUser.Name
> ' no point in listing Administrator
> ' use lowercase letters in the names in the If test!
> If LCase(sAdmGrpUser) <> "administrator" Then
> WScript.Echo sAdmGrpUser
> End If
> Next
> Else
> WScript.Echo "Could not connect to computer: " & sComputer
> End If
> Else
> WScript.Echo sComputer & " is not online"
> End If
> Err.Clear
> Next
> On Error Goto 0
>
>
> Function IsConnectible(sHost, iPings, iTO)
> ' Returns True or False based on the output from ping.exe
> '
> ' Author: Alex Angelopoulos/Torgeir Bakken
> ' Works an "all" WSH versions
> ' sHost is a hostname or IP
>
>
> ' iPings is number of ping attempts
> ' iTO is timeout in milliseconds
> ' if values are set to "", then defaults below used
>
>
> If iPings = "" Then iPings = 2
> If iTO = "" Then iTO = 750
>
>
> Const OpenAsDefault = -2
> Const FailIfNotExist = 0
> Const ForReading = 1
>
>
> Set oShell = CreateObject("WScript.Shell")
> Set oFSO = CreateObject("Scripting.FileSystemObject")
> sTemp = oShell.ExpandEnvironmentStrings("%TEMP%")
> sTempFile = sTemp & "\runresult.tmp"
>
>
> oShell.Run "%comspec% /c ping -n " & iPings & " -w " & iTO _
> & " " & sHost & ">" & sTempFile, 0 , True
>
>
> Set fFile = oFSO.OpenTextFile(sTempFile, ForReading, _
> FailIfNotExist, OpenAsDefault)
>
>
> sResults = fFile.ReadAll
> fFile.Close
> oFSO.DeleteFile(sTempFile)
>
>
> Select Case InStr(sResults,"TTL=")
> Case 0 IsConnectible = False
> Case Else IsConnectible = True
> End Select
> End Function
>
>
>


.



Relevant Pages

  • Input File for Script
    ... I have found the below script online that does ... everything I need to do when searching for members of the local ... that has all of the computers listed that I would like to ...
    (microsoft.public.windows.server.scripting)
  • Re: Add another domain user group to local administrators of all computers in an OU with removing ot
    ... If you have a group "mylocaladmins", which is added to restricted groups, with user1, user2 and user3 you can add or remove accounts to this group without effecting the other users in the group, they will still be local admins. ... But if you have so different needs with separating computers, you have to do a good planning before, what you will achive in for which users/groups. ... Select add on the Members of this group and then add the members ...
    (microsoft.public.windows.server.active_directory)
  • Re: How to create file on network share from ASP.NET
    ... but my point is exactly that both computers ARE ... NOT members of the same domain - one is standalone Win2003 and another is ... Administrators of Unix and Windows domain created for me ... >> asp with password asp which can access shared folder. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: How to create file on network share from ASP.NET
    ... You might want to talk to your network admin ... Juan T. Llibre ... > Thank you for your reply, but my point is exactly that both computers ARE ... > NOT members of the same domain - one is standalone Win2003 and another is ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Group Policy not applying
    ... unusual to have domain controllers in a dmz. ... that can cause problems as domain members can not use ipsec negotiation ... the link below on what ports are required for AD to work through a firewall and pay ... Looking in Event Viewer on all computers involved would also be ...
    (microsoft.public.win2000.group_policy)