The time comes when a manager walks into your office and says “We’re tightening the belt this year. One way we’re looking to save money is to remove unused PCs from 1 area and move it into another area. Give me a list of all PCs that haven’t been used in X days.” You agree to do it without thinking as usual and think no big deal. After a few minutes of looking into it you then think “…ummm, what really does “unused” mean anyway?” Does “unused” mean users aren’t working on it and just use it as a Facebook machine? Does “unused” mean X application isn’t being executed on it or does it simply mean no keyboard or mouse activity at all?

After you grill the manager a little bit you find out that he wants all PCs that haven’t had any kind of keyboard or mouse activity for 1 week. Fine. Game on.

I came across this awesome StackOverflow question which did 90% of the work for me.

This is nearly exactly the same as the author example but I needed to modify it for a mass deployment. All I’m doing it executing the script on a workstation and getting the total idle time in minutes. I’m then adding this to a file called PCNAME-idletime.txt on a server. I’m using ConfigMgr so the deployment of the script was trivial. After all workstations completed and I had a whole bunch of TXT files in the server’s folder I then merged them all into 1 single CSV and voila!, the manager got what he wanted!

This one-liner lists all the text files and using calculated properties creates a name to idle time reference which I then export out into a CSV. What I end up with is something like this:

PCName,Idletime
PC1,345
PC2,123
PC3,0


Don't just learn from my blog and keep that newfound knowledge to yourself! Share it! I've created a new service called TechSnips that's dedicated to helping technology professionals share their knowledge and look awesome in the process! Through small screencast videos, full courses and written content, TechSnips is a community to help you grow your career. Join us!.

I hope this helps the next time you want to get unused PCs!

%d bloggers like this: