I think the problem is with the pipe. You will need to invoke the cmd shell to make it work right.

 Code:
$ShellAd = '%comspec% /c dsquery user -samid ' +  @USERID + ' | dsget user -profile'
Shell $ShellAd


I've never used the ds_tools, but I would bet if you look in the UDF Forum, you will find a number of User Defined Functions already written that will do what you want without the need to shell out.
_________________________
(... better days ahead)