The script below is found at http://www.adminscripteditor.com/scriptlibrary/view.asp?id=261 I modified it a bit to only return the script path and to have the function not display stuff on the screen.

 Code:
$scriptpath = GetScriptpath("usernamegoeshere")
?$scriptpath
Sleep 2

Function GetScriptPath($ADAccountName)
	$filter=" where samAccountName='"+$ADAccountName+"' "
	$AdoCon = CreateObject("ADODB.Connection")
	$AdoCon.Provider = "ADsDSOObject"; Current credentials are used, as username and password aren't specified
	$AdoCon.Open("Active Directory Provider"); Create ADO command object for the connection.
	$AdoCommand = CreateObject("ADODB.Command")
	$AdoCommand.ActiveConnection = $AdoCon
	$AdoCommand.CommandText ="Select AdsPath, samAccountName, GroupType, Scriptpath, Department, " +
	"physicalDeliveryOfficeName from 'LDAP://"+GetObject("LDAP://rootDSE").Get("defaultNamingContext")+"' "+$filter
	;Other fields include: givenname, initials, sn, displayname, telephonenumber, wwwhomepage, url, postofficebox, postalcode, profilepath, homedrive
	;       homedirectory, homephone, pager, mobile, facsimiletelephonenumber, iphone, othertelephone, title, department, company, and others.

	; Execute the query.
	$Recordset = $AdoCommand.Execute
	$ADlookupname=$recordset.Fields("samAccountName").value
	If $ADlookupName <> $ADAccountName
		$GetScriptpath = 13
	Else
		$GetScriptpath = $recordset.fields("scriptpath").value
	EndIf
	$adocon="0"
	$adocommand="0"
	$recordset="0"
EndFunction


Edited by Mart (2008-02-21 08:21 AM)
Edit Reason: Split up the loooong line.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.