Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function get-mountpoints {
  2. [decimal]$threshold = 10
  3. $TotalGB = @{Name="Capacity(GB)";expression={[math]::round(($_.Capacity/ 1073741824),2)}}
  4. $FreeGB = @{Name="FreeSpace(GB)";expression={[math]::round(($_.FreeSpace / 1073741824),2)}}
  5. $FreePerc = @{Name="Free(%)";expression={[math]::round(((($_.FreeSpace / 1073741824)/($_.Capacity / 1073741824)) * 100),0)}}
  6. $volumes = Get-WmiObject -Class win32_volume | Where-object {$_.DriveLetter -eq $null}
  7. $volumes | select SystemName, Label, $TotalGB, $FreeGB, $FreePerc | ?{$_."Free(%)" -gt $threshold} |ConvertTo-Html | Out-String  
  8. }
  9. $messageParameters = @{
  10. Subject = "MyApp Application Mount Point Daily DiskSpace Report " + (Get-Date -Format g)
  11. body = ("my-app" | ForEach-Object {
  12. get-mountpoints $_
  13. } ) | out-string
  14. From = "my-app@mycompany.com"
  15. To = "servernotifications@mycompany.com"
  16. SmtpServer = "internalmail.mycompany.com"
  17. BodyAsHtml = $true
  18. }
  19. Send-MailMessage @messageParameters
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement