Windows 10 - Delete user profile based on desktop shortcut last modified date

Is it possible to delete a Windows 10 user profile if the ‘last modified date’ of C:\users*\Desktop\Phone Book.lnk is older than 60 days? This .lnk file (a shortcut to an Excel file) seems to accurately reflect the last login date of the user and has the added convenience of not showing up under the Public, Default, and Administrator accounts due to it being deployed via GPO.

I’ve researched the other methods of removing aged user profiles including GPO, LastUseTime, LastWriteTime, NTUSER.dat, delprof alternatives, etc. and they all seem to have their pitfalls.

I’m thinking Delete user profiles based on the date of the Appdata\Local folder has the answer but I’m struggling to fit the pieces together.

  • Tried: GPO, LastUseTime, LastWriteTime, NTUSER.dat, delprof alternatives, etc.
  • Expected: Return genuine user last login time.
  • Result: Windows Feature Updates seems to change LastUseTime/LastWriteTime to patch date for all users.

Use the CIM/WMI class Win32_UserProfile it contains both the user profile path and it’s last used time.
Get-CimInstance -ClassName Win32_UserProfile | Select LocalPath, LastUseTime

1 Like

This might help …