Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $path ="S:\Active Files"
- $limit = (Get-Date).AddDays(-30)
- $colItems = (Get-ChildItem $path -Recurse | Measure-Object -property length -sum)
- "{0:N2}" -f ($colItems.sum / 1GB) + " GB"
- if (($colItems.sum/1GB) -gt 36){
- Get-ChildItem -Path $path -Recurse | Where-Object{
- ($_.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'
- $EmFrom = "tld.notifications@gmail.com"
- $username = "tld.notifications@gmail.com"
- $pwd = "It.Admins2018"
- $EmTo = "nefarios@gmail.com"
- $Server = "smtp.gmail.com"
- $port = 587
- $Subj = "TLD Drive Notification"
- $Bod = "Older files list attached (more than 1 month old)"
- $Att = "C:\drive-statistics.txt"
- $securepwd = ConvertTo-SecureString $pwd -AsPlainText -Force
- $cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, $securepwd
- Send-MailMessage -To $EmTo -From $EmFrom -Body $Bod -Subject $Subj -Attachments $Att -SmtpServer $Server -port $port -UseSsl -Credential $cred
- }
- "
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement