I'd like to use get-childitem recursively, but only have it return files not directories. The best solution I have just doesn't seem natural:
gci . *.* -rec | where { $_.GetType().Name -eq "FileInfo" } 3 Answers
Try this:
gci . *.* -rec | where { ! $_.PSIsContainer } 1In Powershell 3.0, it is simpler,
gci -Directory #List only directories gci -File #List only files This is even shorter,
gci -ad # alias for -Directory gci -af # alias for -File 1In powershell 2.0 the best and simplest solution i came up with is to include all files with an extension:
get-childitem -Recurse -include *.* folders doesn't have an extension so they are excluded, beware of no extension named files.
2