March 23, 2010
Today I made my first powershell script and put it in use.
It deletes files older than 30 days in a tree structure, count number of  files removed and total file size removed.


001
002
003
004
005
006
007
008
009
010
$date = [DateTime]::Now.AddDays(-30)
$list = get-childitem L:\scan\ -recurse | where {!$_.PSIsContainer} | where {$_.LastWriteTime -le $date}
$sizetotal = 0
$files =0
foreach ($file in $list)
{$sizetotal = $sizetotal + $file.Length/1MB
 $files++
 Remove-Item $file.fullname -force}
"No of files removed: " + $files
"Total file size in MB: " + "{0:N0}" -f $sizetotal

1 kommentarer:

Unknown said...

How to login into the casino in 2021
Here is https://vannienailor4166blog.blogspot.com/ how herzamanindir to do this: Step herzamanindir.com/ 1. Go to the website. · Click on the “Login” link on the right-hand side. · Click on the “Login” button to septcasino enter a live chat number. · Enter https://septcasino.com/review/merit-casino/ the