Solved

configure dsquery output to display only computer name

Posted on 2014-10-06
4
2,033 Views
Last Modified: 2014-10-06
Hey Experts.  I am outputting all computer accounts that are inactive in my environment using DSQUERY.  Here is the command I'm using currently.

C:\Tools>dsquery computer -limit 0 ou=depts,ou=12,dc=34,dc=56,dc=78,dc=90 >>c:\tools\computers_all.log

The results show way too much information and I want to filter out everything except the hostname.  Anyone know the syntax for this?

Thanks experts!
0
Comment
Question by:samiam41
[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
  • 2
4 Comments
 
LVL 13

Accepted Solution

by:
Gabriel Clifton earned 500 total points
ID: 40363758
dsquery computer -o rdn -limit 0 ou=depts,ou=12,dc=34,dc=56,dc=78,dc=90 >>c:\tools\computers_all.log
0
 
LVL 9

Author Comment

by:samiam41
ID: 40363763
Thank you!!  Glad that's been solved!
0
 
LVL 13

Expert Comment

by:Gabriel Clifton
ID: 40363772
No problem, I do that command all the time.
0
 
LVL 28

Expert Comment

by:Dan McFadden
ID: 40363778
Are you open to using Powershell?  It would be much easier.

Get-ADComputer -Property Name, lastLogonDate -filter * | where lastLogonDate -lt (Get-Date).AddDays(-500) | select Name,lastLogonDate,DistinguishedName,Enabled | Export-Csv test.csv -noTypeInformation -UseCulture

Open in new window


*** Note:  to adjust the age of the the inactivity,  adjust the number in here:  (Get-Date).AddDays(-500)
*** this indicates inactivity over 500 day.  for computers that haven't been active for 90 or more days, use 90.

This will give you a CSV file that you can use in Excel.


Dan
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

For anyone that has accidentally used newSID with Server 2008 R2 (like I did) and hasn't been able to get the server running again because you were unlucky (as I was) and had no backups - I was able to get things working by doing a Registry Hive rec…
This process allows computer passwords to be managed and secured without using LAPS. This is an improvement on an existing process, enhanced to store password encrypted, instead of clear-text files within SQL
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
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

623 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