Need help with scripting

Neptune IT
Neptune IT used Ask the Experts™
Can someone tell me script to get all the computer names in AD  in specific OU with Last logon date.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2007
$computers = Get-ADComputer -Filter * -SearchBase "OU=OUName,DC=domain,DC=com" -Properties lastlogontimestamp

Open in new window

Klavs RDeveloper, owner of AlbusBit

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.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial