Created
August 4, 2019 02:09
-
-
Save shimo164/ae25fd75f67310ad8e5411daea46129d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### 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