Here is a little package that includes a wrapper for dsquery. You could use the action to load the dn variable then call the dsrm action.
dn = System.getModule("sample").dsqueryExample("Computer","Computer","cn","computername",1,true,"username","password")[0].get("distinguishedName");
I'm not too sure if the piping should work or not... seems like it should but maybe you are hitting a bug.