Lingering Objects and Powershell

Is there a way to find Lingering Objects in AD through Powershell commands on the DCs?
LVL 1
Indie101Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RobertSystem AdminCommented:
Not sure if I am understanding your question correclty or not but if you mean finding stale computer objects you could use get-adcomputer and use a filter based on last logon. (note the filter usea a date so you would need to get the date and subtract the number of days)

something like
 
$date = (Get-Date).Adddays(-(60))
Get-ADComputer -Filter {LastLogonTimeStamp -lt $date} 

Open in new window


I personally just use dsquery (you could call from within powershell if you want but just as easy to run from cmd).
dsquery computer DC=domain,DC=com -inactive 15 -limit 0 >> C:\inactivePC-15-weeks.txt

Open in new window


You can do either for users also.
0
Kevin StanushApplication DeveloperCommented:
No, I don't believe there is a one-size-fits-all command to show lingering objects, but here is a good tech article that covers all of the bases, depending on what o/s version you have:

https://support.microsoft.com/en-us/help/910205/information-about-lingering-objects-in-a-windows-server-active-directo
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.