Solved

configure dsquery output to display only computer name

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

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

Join & Write a Comment

Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
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…
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now