Skip to content

Instantly share code, notes, and snippets.

@shimo164
Created August 4, 2019 02:09
Show Gist options
  • Select an option

  • Save shimo164/ae25fd75f67310ad8e5411daea46129d to your computer and use it in GitHub Desktop.

Select an option

Save shimo164/ae25fd75f67310ad8e5411daea46129d to your computer and use it in GitHub Desktop.
### Parameter $path
### if recursively use: Get-ChildItem -r
### file size is in MB
$path = '.\'
$items = @(Get-ChildItem $path)
$Output =
foreach ($item in $items) {
if ( $item -isnot [System.IO.DirectoryInfo] ){
$h = @(Get-FileHash -Algorithm MD5 $item)
$s = [Math]::Round($item.Length / 1024/ 1024, 1, [MidpointRounding]::AwayFromZero);
New-Object -TypeName PSObject -Property @{
_Directory = $item.DirectoryName
_Name = $item.Name
_Size_MB = $s
_Hash = $h.Hash
} | Select-Object _Directory,_Name,_Size_MB,_Hash
}
}
$Output | Export-Csv -Encoding UTF8 .\filehash.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment