Skip to content

Instantly share code, notes, and snippets.

@shinjijai
Last active April 17, 2018 17:17
Show Gist options
  • Save shinjijai/ff7959110ff60edd47692554eee00d80 to your computer and use it in GitHub Desktop.
Save shinjijai/ff7959110ff60edd47692554eee00d80 to your computer and use it in GitHub Desktop.
Takes an array of folder locations and exports a CSV file with the file hash, name and directory name.
$FolderLocation = @("FilePath1", "FilePath2", "FilePath3")
$AllFiles = @()
$FileList = @()
foreach($RootFolder in $FolderLocation) {
$AllFiles += Get-ChildItem -Path $RootFolder -File -Recurse
}
foreach($File in $AllFiles) {
$FileHash = Get-FileHash $File.PSPath | Select-Object Hash -ExpandProperty Hash
$FileInfo = [PSCustomObject]@{
Folder = $File.DirectoryName
FileName = $File.Name
"FileSize (KB)" = [math]::Round($File.Length / 1KB,2)
FileHash = $FileHash
}
$FileList += $FileInfo
}
$Filelist | Export-CSV -NoTypeInformation "File Information.csv"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment