Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Original by martijnaa (https://www.reddit.com/user/martijnaa)
- ## https://www.reddit.com/r/PowerShell/comments/3fqtlk/simple_script_look_for_large_files/
- ## 04/08/2015
- Function Get-LargeFiles {
- Param (
- [parameter(Mandatory=$true)]
- [long]$size,
- [parameter(Mandatory=$true)]
- [ValidateScript({Test-Path $_ -PathType 'Container'})]
- [string]$location,
- [parameter(Mandatory=$false)]
- [ValidateScript({Test-Path $_ -IsValid})]
- [string]$export
- )
- $results = Get-ChildItem "$location\" -Recurse | Where-Object {$_.Length -gt $size} | Select FullName, @{Name="Size(MB)";Expression={"{0:N1}" -f($_.Length/1MB)}} | Sort-Object "Size(MB)" -desc
- If ($export) {
- $results | Export-csv $export -NoTypeInformation
- }
- Else {
- $results
- }
- }
- Get-LargeFiles -size 100MB -location C:\folder-with-large-files -export E:\largefiles.csv
Add Comment
Please, Sign In to add comment