Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Get-ChildItem D: -Recurse -File | Measure-Object | %{$_.Count}
- $Count = Get-ChildItem D: -Recurse -File | Measure-Object | %{$_.Count}
- $Status= $Event.Message
- $From = "sender@sender.com"
- $To = "receiver"
- $SMTPServer = "smtp"
- $SMTPPort = "587"
- $Username = "email@email.us"
- $Password = "password"
- $Subject = "$computer,Files count"
- $Body = "Number of Files is $Count |D drive test "
- $smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort);
- $smtp.EnableSSL = $false
- $smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
- $smtp.Send($From, $To, $subject, $body);
- $computer = "$env:computername
- if ($Count -lt 60) {
- $Body = "Number of Files is low at $Count |D drive test "
- } else {
- $Body = "Number of Files is $Count which is large |D drive test "
- }
- if ($count -le '50') {
- $Body = 'your text'
- }
- elseif (($count -gt '50') -and ($count -le '100')) {
- $Body = 'your text'
- }
- elseif (($count -gt '100') -and ($count -le '500')) {
- $Body = 'your text'
- }
- else {
- $Body = 'your text'
- }
- $folder = "C:myfolder"
- $folderSize = ( Get-ChildItem $folder -Recurse -Force | Measure-Object -Property Length -Sum ).Sum
- If ( $folderSize -lt 1KB ) { $folderSizeOutput = "$("{0:N2}" -f $folderSize) B" }
- ElseIf ( $folderSize -lt 1MB ) { $folderSizeOutput = "$("{0:N2}" -f ($folderSize / 1KB)) KB" }
- ElseIf ( $folderSize -lt 1GB ) { $folderSizeOutput = "$("{0:N2}" -f ($folderSize / 1MB)) MB" }
- ElseIf ( $folderSize -lt 1TB ) { $folderSizeOutput = "$("{0:N2}" -f ($folderSize / 1GB)) GB" }
- Write-Output $folderSizeOutput
- if ($folderSize -le '46Gb') {
- $Body =="Folder size is less then previos"
- }
- f ($folderSize -Gt '46Gb') {
- $Body =="Folder size is less then previos"
- }
- $Count=Get-ChildItem D: -Recurse -File | Measure-Object | %{$_.Count}
- if ($count -le '56') {
- $Body = "Number of Files is less than previous $Count which was 56 @ D drive test "
- } else {
- $Body = "Number of Files is $Count which is large |D drive test "
- }
- if ($count -gt '56') {
- $Body = "Number of Files is larger than previous $Count which was 56 @ D drive test "
- } else {
- $Body = "Number of Files is $Count which is large |D drive test "
- }
- $From = "sender@sender.com"
- $To = "receiver"
- $SMTPServer = "smtp"
- $SMTPPort = "587"
- $Username = "email@email.us"
- $Password = "password"
- $Subject = "$computer,Files count"
- $Body = "Number of Files is $Count |D drive test "
- $smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort);
- $smtp.EnableSSL = $false
- $smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
- $smtp.Send($From, $To, $subject, $body);
- $computer = $env:computername
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement