I need to locate a .exe file and run it, only knowing the directory which is a few levels higher than the .exe file
EG If I have this folder structure:
and I only know the test folder, I need to get the path to program.exe, without knowing the name of the .exe file either (but there is only one .exe file).
So something like:
gcm *.exe test
This sounds like what you're looking for:
$path = 'test' $program = Get-ChildItem -Path $path -Filter *.exe -Recurse & $program.FullName
& operator there is the call operator; it can run an executable given the full path to it.