Solved

configure dsquery output to display only computer name

Posted on 2014-10-06
4
1,921 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

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

This article explains the steps required to use the default Photos screensaver to display branding/corporate images
This article shows the method of using the Resultant Set of Policy Tool to locate Group Policy that applies a particular setting.
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will give you a basic overview of Windows Live Photo Gallery and show you various editing filters and touches to photos you can apply. This will be demonstrated using Windows Live Photo Gallery on Windows 7 operating system.

734 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