Solved

dsquery computer > file.txt problems

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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Active Directory security has been a hot topic of late, and for good reason. With 90% of the world’s organization using this system to manage access to all parts of their IT infrastructure, knowing how to protect against threats and keep vulnerabil…
Uncontrolled local administrators groups within any organization pose a huge security risk. Because these groups are locally managed it becomes difficult to audit and maintain them.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Suggested Courses

627 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