So I was at a costumer. They wanted an export of the file size that files older than 7 years populate on the file server. I made a very simple script that does the job.
$Locatie = "D:\" #Verander het cijfer om het aantal jaar aan te passen $Datum = (Get-Date).AddYears(-7) $Outfile = ".\Output.txt" $List = @(GCI $Locatie -Recurse | Where {$_.LastWriteTime -lt $Datum}) $Outinfo = "De lijst bevat "+ $list.count +" bestanden" Add-Content -Path $Outfile -Value $Outinfo $Bytes = 0 ForEach ($Item in $List){($Bytes=$Bytes + [int]$Item.length)} $Outinfo = "De Bestanden bevatten $Bytes bytes" Add-Content -Path $Outfile -Value $Outinfo $Outinfo = "Dat is "+ $Bytes/1048576 +" MegaBytes" Add-Content -Path $Outfile -Value $Outinfo