Powershell - Get files or Folder list

2011/01/12 | less than 1 minute read |

Update: PowerShell version 3 now have a parameter -File and -Directory

Here is quick tip if you want to retrieve recursive either files or folder in PowerShell”

Directories

PowerShell version 2

Get-childitem -Path c:\ -recurse | 
    Where-Object -FilterScript {
        $_.PsIsContainer
    }

PowerShell version 3+

Get-childitem -Path c:\ -recurse -Directory

Files

PowerShell version 2

Get-childitem -Path c:\ -recurse | 
    Where-Object -FilterScript {
        -not $_.PsIsContainer
    }

PowerShell version 3+

Get-childitem -Path c:\ -recurse -File

Leave a comment