Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

configure dsquery output to display only computer name

Posted on 2014-10-06
4
Medium Priority
?
2,340 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 2000 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 29

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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

Wouldn't it be nice if objects in Active Directory automatically moved into the correct Organizational Units? This is what AutoAD aims to do and as a plus, it automatically creates Sites, Subnets, and Organizational Units.
It’s time for spooky stories and consuming way too much sugar, including the many treats we’ve whipped for you in the world of tech. Check it out!
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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

916 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