dsquery computer > file.txt problems

I am trying to get the host names of all computers in a specific OU to a text file. My initial thought was:
ds query computer OU=computers.... | dsget computer -samid | find "$" > file.txt

I am doing the find "$" to remove the first and last line in the text file. My problem is there is always a $ at the end of the names and I can't figure out how to remove it before or after the redirect.

I am sure I am going about this all wrong or just can't figure out the simple command that will exclude the $ from the redirect

Microsoft server 2K8 environment
Who is Participating?
xylogConnect With a Mentor Commented:
Not as elegant, but you can do this from the command line to strip the dollar signs:

for /f "delims=$" %i in ('dsquery computer ^|dsget computer -samid') do @echo %i

Please not from a batch file you need to use %%i in place of %i above.
Mike KlineCommented:
Can I suggest another tool adfind by Joe Richards  http://www.joeware.net/freetools/tools/adfind/index.htm

adfind -b "DN of your OU"  -f objectcategory=computer  name -nodn


Get a copy of the GNU Stream editor for windows -> http://gnuwin32.sourceforge.net/packages/sed.htm

dsquery computer |dsget computer -samid |sed s/\$//g
JD_PowersAuthor Commented:
Unfortunately we have a strict software policy, and anything that is not native to Microsoft. So command line, powershell, and vbscript are the network limits. Although I am not a VB guy.
Have you looked at LDIFDE:   http://support.microsoft.com/kb/237677 

It is not additional software.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.