I currently have a batch file that looks to see if a folder exists and then if it does it runs the uninstall exe within it and then installs the program with an msi. I need to alter it or just convert it to powershell so that it first checks the age of the folder before continuing. The age I was thinking I would use would be older than 12 months. A problem that I kept running into was that I need to use a wildcard to check if the directory exists due to it being slightly different on each computer at the end of the name. Here is what I have so far with nothing related to age included.
@echo off
IF exist C:\ProgramData\bomgar* ( goto Uninstall ) ELSE ( goto Install )
:Uninstall
cd C:\ProgramData\bomgar*
remove.exe
:Install
msiexec /i "C:\pathtomsi"
:End
Echo Test Complete
Any help or advice would be greatly appreciated.