Advertisement
Guest User

Untitled

a guest
Mar 10th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. Get-ChildItem D: -Recurse -File | Measure-Object | %{$_.Count}
  2.  
  3. $Count = Get-ChildItem D: -Recurse -File | Measure-Object | %{$_.Count}
  4. $Status= $Event.Message
  5. $From = "sender@sender.com"
  6. $To = "receiver"
  7. $SMTPServer = "smtp"
  8. $SMTPPort = "587"
  9. $Username = "email@email.us"
  10. $Password = "password"
  11. $Subject = "$computer,Files count"
  12. $Body = "Number of Files is $Count |D drive test "
  13. $smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort);
  14. $smtp.EnableSSL = $false
  15. $smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
  16. $smtp.Send($From, $To, $subject, $body);
  17. $computer = "$env:computername
  18.  
  19. if ($Count -lt 60) {
  20. $Body = "Number of Files is low at $Count |D drive test "
  21. } else {
  22. $Body = "Number of Files is $Count which is large |D drive test "
  23. }
  24.  
  25. if ($count -le '50') {
  26. $Body = 'your text'
  27. }
  28. elseif (($count -gt '50') -and ($count -le '100')) {
  29. $Body = 'your text'
  30. }
  31. elseif (($count -gt '100') -and ($count -le '500')) {
  32. $Body = 'your text'
  33. }
  34. else {
  35. $Body = 'your text'
  36. }
  37.  
  38. $folder = "C:myfolder"
  39. $folderSize = ( Get-ChildItem $folder -Recurse -Force | Measure-Object -Property Length -Sum ).Sum
  40. If ( $folderSize -lt 1KB ) { $folderSizeOutput = "$("{0:N2}" -f $folderSize) B" }
  41. ElseIf ( $folderSize -lt 1MB ) { $folderSizeOutput = "$("{0:N2}" -f ($folderSize / 1KB)) KB" }
  42. ElseIf ( $folderSize -lt 1GB ) { $folderSizeOutput = "$("{0:N2}" -f ($folderSize / 1MB)) MB" }
  43. ElseIf ( $folderSize -lt 1TB ) { $folderSizeOutput = "$("{0:N2}" -f ($folderSize / 1GB)) GB" }
  44. Write-Output $folderSizeOutput
  45.  
  46. if ($folderSize -le '46Gb') {
  47. $Body =="Folder size is less then previos"
  48. }
  49.  
  50. f ($folderSize -Gt '46Gb') {
  51. $Body =="Folder size is less then previos"
  52. }
  53.  
  54. $Count=Get-ChildItem D: -Recurse -File | Measure-Object | %{$_.Count}
  55. if ($count -le '56') {
  56. $Body = "Number of Files is less than previous $Count which was 56 @ D drive test "
  57. } else {
  58. $Body = "Number of Files is $Count which is large |D drive test "
  59. }
  60.  
  61. if ($count -gt '56') {
  62. $Body = "Number of Files is larger than previous $Count which was 56 @ D drive test "
  63. } else {
  64. $Body = "Number of Files is $Count which is large |D drive test "
  65. }
  66.  
  67. $From = "sender@sender.com"
  68. $To = "receiver"
  69. $SMTPServer = "smtp"
  70. $SMTPPort = "587"
  71. $Username = "email@email.us"
  72. $Password = "password"
  73. $Subject = "$computer,Files count"
  74. $Body = "Number of Files is $Count |D drive test "
  75. $smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort);
  76. $smtp.EnableSSL = $false
  77. $smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
  78. $smtp.Send($From, $To, $subject, $body);
  79. $computer = $env:computername
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement