break on
; This script demonstrates how to use Actice Directory Services Interface (ADSI)
; to enumerate all file shares on local and remote computers
; To redirect output to a file, specify $pipe=filename on commandline
$server_name = "dn1cov" ; change to your hostname
if $pipe
del "$pipe"
$rs = redirectoutput ( "$pipe" )
endif
?"Enumerating shares on $server_name ..."
$lms = olegetobject ( 0, "WinNT://$server_name/lanmanserver" )
if $lms = 0
"Active Data Services Interface (ADSI) not installed on this machine"
exit
endif
$enum = oleenumobject( $lms )
while @error = 0
$share = oleenumobject( $lms, $enum )
if @error = 0
?
?"Name : " olegetproperty( $share , "name" )
?"Description: " olegetproperty( $share , "description" )
?"Path : " olegetproperty( $share , "path" )
?"Connections: " olegetproperty ( $share, "currentusercount" )
endif
loop
if $enum
$rs = olereleaseobject ( $enum )
endif
if $share
$rs = olereleaseobject ( $share )
endif
if $lms
$rs = olereleaseobject ( $lms )
endif
?
exit