Solved

dsquery computer > file.txt problems

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

In this article, we will see the basic design consideration while designing a Multi-tenant web application in a simple manner. Though, many frameworks are available in the market to develop a multi - tenant application, but do they provide data, cod…
In-place Upgrading Dirsync to Azure AD Connect
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…
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.

791 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