Home > Microsoft, PowerShell > PowerShell: Enumerate Files recursive and get full path for each file

PowerShell: Enumerate Files recursive and get full path for each file

To enumerate all files of a specific path recursive and get the full path for each file using Microsoft PowerShell:


Get-ChildItem -rec | ForEach-Object -Process {$_.FullName}

to capture the output and generate an XML file do:


Get-ChildItem -rec | ForEach-Object -Process {$_.FullName} | Export-Clixml c:\temp\report.xml

to only enumerate / list files, use the psIsContainer switch:


Get-ChildItem -rec | Where-object {!$_.psIsContainer -eq $true} | ForEach-Object -Process {$_.FullName}

or for folders only:


Get-ChildItem -rec | Where-object {!$_.psIsContainer -eq $false} | ForEach-Object -Process {$_.FullName}

Categories: Microsoft, PowerShell Tags: list, PowerShell
  1. No comments yet.
  1. No trackbacks yet.
WordPress SEO fine-tune by Meta SEO Pack from Poradnik Webmastera