Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $numberOfDays = ""
  2. $pathToArchive = ""
  3. $csvPath = ""
  4.  
  5.  
  6. Function Get-ArchivableFiles
  7.  
  8. {
  9.  
  10.  Param([string[]]$path,
  11.  
  12.        [int]$numberDays)
  13.  
  14.  $cutOffDate = (Get-Date).AddDays(-$numberDays)
  15.  
  16.  Get-ChildItem -Path $path -recurse |
  17.  
  18.  Where-Object {$_.LastAccessTime -le $cutOffDate}
  19.  
  20. }
  21.  
  22. $results = Get-ArchivableFiles -path $pathToArchive -numberDays $numberOfDays  | select name, fullname, length, lastaccesstime
  23.  
  24. $results | Export-CSV $csvPath
  25.  
  26. $results | measure -sum length | % {$_.sum / 1gb}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement