powershell - Find specific extension from directory -
i have root directory contains several child directories , inside 1 of them have .ps1
file want get:
function getfilenames { $folders = get-childitem "c:\myfolder" $filename = [system.io.directory]$folders[0].getfiles($folders[0].fullname, "*.ps1", "alldirectories") }
so inside path: c:\myfolder
have several folders , want take first folder , inside folder find .ps1 file
. $filename
value empty.
you can select first item , call get-childitem
cmdlet again:
function getfilenames { get-childitem "c:\myfolder" -directory | select -first 1 | get-childitem -filter '*.ps1' -recurse | select -expand name }
but looks little bit awkward me. wan't achieve?
Comments
Post a Comment