break on$fname = "Paul" ;The user's first name
$Lname = "Berquam" ;
$exch = "Y" ;
? "Searching for $fname $lname" ?
;options.txt is a file with the following
;
;[Export]
;Subcontainers=Yes
;Basepoint=/o=<ORGNAME>/ou=<SITENAME>/cn=<CONTAINERNAME>
;
;End of options.txt
;note: The container is optional, if you don't enter it it should go to the GAL
if $exch = "Y"
$exchadminpath = readvalue("HKEY_LOCAL_MACHINE\Software\Microsoft\Exchange\Setup","AdminDest")
$exchfile = "c:\temp\testexch.csv"
$options = "c:\options.txt"
$DSNAME = "YOUREXCHANGESERVERNAME" ;Directory server name
if exist($exchfile)
del "$exchfile"
endif
$nul = open (7,$exchfile,1)
$nul = close(7)
shell "$exchadminpath\admin.exe /e $exchfile /d $DSNAME /o $options" ;for export
;Note that you can include a /n switch so that it doesn't display the gui export screen. ;I kept it so that I could be sure that it was it was doing something
$found = 0
$found2 = 0
$count = 0
$countfirst = 0
$countlast = 0
$line = "none"
$nul = open(7,$exchfile,2)
? "Searching..."
while $line <> ""
$line = readline(7) "."
$count = $count + 1
$found = instr($line,$fname) ; ? "$fname $line"
if $found <> 0
$countfirst = $countfirst + 1
$found2 = instr($line,$lname)
if $found2 <> 0
$mailstart = instr($line,"SMTP:")
$linelen = len($line)
$line2 = substr($line,$mailstart,$linelen - $mailstart)
$mailend = instr($line2,"%")
$mailaddy = substr($line2,6,$mailend-6)
$countlast = $countlast + 1
endif
endif
loop
$nul = close(7)
? "$count records searched"
if $countlast > 0
? "$fname $lname found"
? "Mail address is $mailaddy"
else
? "$fname $lname not found"
endif
endif
? ? "$countfirst name(s) matching $fname"
? "$countlast name(s) matching $lname"
? "End"
get $c