Solved

dsquery computer > file.txt problems

Posted on 2010-09-14
5
1,572 Views
Last Modified: 2012-05-10
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
0
Comment
Question by:JD_Powers
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 57

Expert Comment

by:Mike Kline
ID: 33677284
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

Thanks

Mike
0
 
LVL 5

Expert Comment

by:xylog
ID: 33681814
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
0
 

Author Comment

by:JD_Powers
ID: 33684151
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.
0
 
LVL 26

Expert Comment

by:pony10us
ID: 33684517
Have you looked at LDIFDE:   http://support.microsoft.com/kb/237677 

It is not additional software.
0
 
LVL 5

Accepted Solution

by:
xylog earned 125 total points
ID: 33685414
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.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question