ok.... Here it is, beat it up and see what you think. Suggestions are appreciated. Efficiency is king...

without the optional IP parameter it will return ALL the info for ALL leases. The IP parameter will limit the return to just that IP.

obviously, this requires a MS DHCP server and the dhcpcmd.exe tool from the reskit in @scriptdir... I may change it to so %path% would be sufficient, but that is no big deal
http://www.dynawell.com/reskit/microsoft/win2000/dhcpcmd.zip

code:
 
break on

$return = EnumMAC('192.168.110.2', '192.168.110.0','192.168.110.12')
for $x=0 to ubound($return,2)
? 'IP: ' + $return[0,$x]
? 'Host: ' + $return[1,$x]
? 'MAC: ' + $return[2,$x]
next

Function EnumMAC($server, $subnet, Optional $ip)
DIM $DHCPCMD, $command, $line, $x, $addr, $host, $mac
DIM $arrTemp[2,0]

$x = 0
$command = 'cmd /c '+@scriptdir+'\dhcpcmd.exe '+ $server +' enumclients ' + $subnet+' -h'
if $ip
$command = $command + ' | find "' + $ip + '"'
endif
$output = WSHPipe($command,1)

For each $line in $output
if val(left($line,1))
$arrTemp[0,$x] = trim(substr($line,4,15))
$arrTemp[1,$x] = split(trim(substr($line,21,16)),'.')[0]
$arrTemp[2,$x] = trim(substr($line,37,16))
$x = $x +1
redim preserve $arrTemp[2,$x]
endif
next
if $x
redim preserve $arrTemp[2,$x-1]
$EnumMAC = $arrTemp
else
exit (1)
endif
EndFunction
;********************************************************************************************
Function WshPipe($ShellCMD, OPTIONAL $NoEcho)
Dim $WshShell, $oExec, $AllOutput, $Exit, $WshExitCode
$WshErrorMsg=""
$WshShell=CreateObject("WScript.Shell")
$oExec=$WshShell.Exec($ShellCMD)
While $Exit<>1
Dim $Output
Select
Case Not $oExec.StdOut.AtEndOfStream $Output=$oExec.StdOut.ReadAll
Case Not $oExec.StdErr.AtEndOfStream $Output=$oExec.StdErr.ReadAll
$WshErrorMsg = $Output
Case 1 $Output=-1
EndSelect
If $Output=-1
If $oExec.Status=1 $Exit=1 Endif
Else
If $NoEcho<>1 ? $Output Endif
$AllOutput = $AllOutput + $Output
Endif
Loop
$WshExitCode=$oExec.ExitCode
$WshPipe=split($AllOutput,chr(10))
Exit($WshExitCode)
EndFunction

I'll eventually post this over to UDF after if gets beaten up a while.

Jens, this might be a nice addon to KSMS

[ 19. April 2003, 06:32: Message edited by: Radimus ]
_________________________
How to ask questions the smart way <-----------> Before you ask