powershell - Find a file efficiently of which I know the sub path but not the root folder -
i'm making build file in powershell. build file needs reference visual studio 2017 version of msbuild.exe. unfortunately path file depends on edition of visual studio have installed.
for example:
c:\program files (x86)\microsoft visual studio\2017\community\msbuild\15.0\bin c:\program files (x86)\microsoft visual studio\2017\pro\msbuild\15.0\bin
of course can use
$partial = ${env:programfiles(x86)} + '\microsoft visual studio\2017\' get-childitem -path $partial -filter 'msbuild.exe' -recurse
but there lot of other files , folders under c:\program files (x86)\microsoft visual studio\2017\
.
unfortunately doesn't work:
get-childitem -path $partial -filter '\msbuild\15.0\bin\msbuild.exe' -recurse
is there way can give powershell better hint msbuild.exe?
get-childitem support wildcards. specific part of string changes (pro / community) replace wildcard.
c:\program files (x86)\microsoft visual studio\2017\*\msbuild\15.0\bin
in fact can use get-item full wildcard path.
get-item "c:\program files (x86)\microsoft visual studio\2017\*\msbuild\15.0\bin\msbuild.exe"
this return , files matching , assuming each user have 1 installed version of visual studio, 1 file.
Comments
Post a Comment