Skip to content

Instantly share code, notes, and snippets.

@itn3000
Last active October 5, 2016 07:36
Show Gist options
  • Save itn3000/715bc152688c17003611ec15ba527321 to your computer and use it in GitHub Desktop.
Save itn3000/715bc152688c17003611ec15ba527321 to your computer and use it in GitHub Desktop.
get fileinfo in the current directory recursively using powershell
param([string]$location=$(Get-Location).Path)
$parentDir = Split-Path $location -Parent
ls -recurse $location `
|where-object {$_.DirectoryName -ne "" -and $_.DirectoryName -ne $null} `
|foreach-object{new-object PSObject -prop @{DirectoryName=[regex]::Replace($_.DirectoryName,"$($parentDir.Replace("\","\\"))[\\]*","");FileName=$_.Name;Version=$_.VersionInfo.ProductVersion;FileLength=$_.Length;LastUpdate=$_.LastWriteTime}} `
|select-object DirectoryName,FileName,FileLength,Version,LastUpdate `
|ConvertTo-Csv -notypeinformation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment