I want to take path of one of two identical file in a folder. I'm using:
Get-ChildItem C:\Folder\SomeSubFolder\AnotherFolder\LastFolder\ -recurse -Filter *Someexefiles.exe
How can I modify this code?
The below will give you the name & full path for the shortest name found from the results of your filter.
Get-ChildItem C:\Folder\SomeSubFolder\AnotherFolder\LastFolder\ -recurse -Filter *Someexefiles.exe | Select Name, FullName, @{Name = "NameLength"; Expression = {$_.Name.Length}} | Sort NameLength | Select Name,FullName -First 1
If it is the full path that you need to be the shortest its should just be a case of replacing Expression = {$_.Name.Length}
with Expression = {$_.FullName.Length}