I am trying to uninstall a program based on the last used/accessed date. I know there is property attribute that shows Accessed date.
How can I get the date programtically in PowerShell, so I can compare it against the requirement.
The only think I know is the DisplayName of the program from HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
.
From there I can get InstallLocation, but I don't know the name of the .exe file, so don't know how to get that.
How can I get the path to .exe
file for this program and get the date.
Input = DisplayName OutPut = Accessed Date
once I have the path, I can run
Get-ChildItem "C:\Program Files (x86)\Foxit Software\Foxit Reader\FoxitReader.exe" | select lastaccesstime
LastAccessTime
--------------
8/17/2017 3:07:17 PM
FoxitReader is just an example. The logic/code should cover other applications as well like Photoshop.