Solved

dsquery computer > file.txt problems

Posted on 2010-09-14
5
1,526 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
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

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 …
Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html) provided 218 attendees with a step-by-step guide for identifying Acti…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

776 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