How does this work for you?
Code:
break on
$ = setoption('Explicit', 'On')
dim $inFile, $outFile, $curServer
dim $admins,$member,$
; list of servers
$inFile = 'c:\Servers.txt'
; results
$outFile = 'c:\ServerAdmins.txt'
$ = open(1,$inFile)
if exist($outFile)
del $outFile
endif
$ = redirectoutput($outFile)
$curServer = trim(readline(1))
while @error = 0
ucase($curServer) ':'
if cstr(wmiPing($curServer))
$admins = getobject('WinNT://' + $curServer + '/Administrators')
if @error = 0
for each $member in $admins.Members
? $member.Name
next
else
? 'Error: ' @serror
endif
else
? 'Warning: Does not ping'
endif
? ?
$curServer = trim(readline(1))
loop
Function wmiPing($Address,Optional $Timeout,Optional $BlockSize)
Dim $Query,$oWMI,$oItem,$cItems
$Query = "Select ResponseTime,StatusCode From Win32_PingStatus Where Address='" + $Address + "'"
If $Timeout
$Query = $Query + " And TimeOut=" + $Timeout
EndIf
If $BlockSize
$Query = $Query + " And BufferSize=" + $BlockSize
EndIf
$oWMI = GetObject("winmgmts:root\cimv2")
$cItems = $oWMI.ExecQuery($Query)
For Each $oItem In $cItems
If (VarTypeName($oItem.StatusCode) = 'Null') Or $oItem.StatusCode
Exit 1
Else
$wmiPing = $oItem.ResponseTime
EndIf
Next
EndFunction