Need help with scripting

Hi,
Can someone tell me script to get all the computer names in AD  in specific OU with Last logon date.
LVL 1
Neptune ITAsked:
Who is Participating?
 
sirbountyConnect With a Mentor Commented:
$computers = Get-ADComputer -Filter * -SearchBase "OU=OUName,DC=domain,DC=com" -Properties lastlogontimestamp

Open in new window

2
 
Klavs RDeveloper, owner of AlbusBitCommented:
How accurate data you need?
If you need to locate stale computers then lastlogontimestamp is good enough.
But for more precise data you need to use lastlogon and since it is not replicated field, you need to iterate all your domain controllers to get the most recent value.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.