Advertisement
Guest User

t

a guest
Jul 6th, 2018
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. $path ="S:\Active Files"
  2. $limit = (Get-Date).AddDays(-30)
  3. $colItems = (Get-ChildItem $path -Recurse | Measure-Object -property length -sum)
  4. "{0:N2}" -f ($colItems.sum / 1GB) + " GB"
  5.  
  6. if (($colItems.sum/1GB) -gt 36){
  7.  
  8. Get-ChildItem -Path $path -Recurse | Where-Object{
  9. ($_.Length /1MB) -gt 50 } | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit } | select fullname, lastwritetime, @{n="Size MB";e={$_.Length/1MB}} | Sort-Object -Property lastwritetime -descending | export-csv 'C:\drive-statistics.txt'
  10. $EmFrom = "tld.notifications@gmail.com"
  11. $username = "tld.notifications@gmail.com"
  12. $pwd = "It.Admins2018"
  13. $EmTo = "nefarios@gmail.com"
  14. $Server = "smtp.gmail.com"
  15. $port = 587
  16. $Subj = "TLD Drive Notification"
  17. $Bod = "Older files list attached (more than 1 month old)"
  18. $Att = "C:\drive-statistics.txt"
  19. $securepwd = ConvertTo-SecureString $pwd -AsPlainText -Force
  20. $cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, $securepwd
  21. Send-MailMessage -To $EmTo -From $EmFrom -Body $Bod -Subject $Subj -Attachments $Att -SmtpServer $Server -port $port -UseSsl -Credential $cred
  22. }
  23.  
  24.  
  25.  
  26.  
  27. "
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement