Last active
February 20, 2021 16:32
-
-
Save tevkar/f1633e86a7aa3def560cb1446faaa17c to your computer and use it in GitHub Desktop.
Total size of files older than a specific number of days
This file contains 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
# Provided by itefix.net | |
Param | |
( | |
[string]$path, | |
[int]$numberDays | |
) | |
$cutOffDate = (Get-Date).AddDays(-$numberDays) | |
$results = | |
Get-ChildItem -Path $path -recurse | | |
Where-Object {$_.LastAccessTime -le $cutOffDate} | | |
select name, fullname, length, lastaccesstime | |
$size = ($results | measure -sum length | % {$_.sum / 1gb}).ToString("#.##") | |
Write-Host "Path: $path, Age: $numberDays days, size: $size GB" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: .\File_Size_With_Age.ps1 -path c:\temp -numberDays 90
Provided by itefix.net