locked
check status health hard disk (raid) RRS feed

  • Question

  • Hi Everyone,

    Could you help me please with getting notification Health Disk status on email , what I did wrong I received empty email I did not see any info, thank you very much !!

    $ServerName = "myservername"
    $sender = "sender@email"
    $Subject = $ServerName + " - Check Disk Health " + $TimeNow.datetime
    
    
    $SmtpServer = "SMTPmyserver"
    
    $logs = Get-PhysicalDisk | Sort Size | FT FriendlyName, Size, MediaType, SpindleSpeed, deviceid, HealthStatus, IsOffline, OperationalStatus -AutoSize
    $LogOnRecords = "Health Disk Check"
    
    
        Send-MailMessage -To "my@email.com" -from $sender `
        -subject $Subject -Smtp $SmtpServer `
        -body $LogOnRecords

    Thursday, October 17, 2019 3:09 PM

Answers

  •    Send-MailMessage -To "my@email.com" -from $sender `
        -subject $Subject -Smtp $SmtpServer `
        -body ($logs|Out-String)


    \_(ツ)_/

    • Marked as answer by Mooner09 Thursday, October 17, 2019 5:11 PM
    Thursday, October 17, 2019 4:28 PM

All replies

  • You should have received an e-mail with "Health Disk Check" in the message body.

    If you want the contents of the $logs variable in the message body you'll have to put those contents either in the "-body" parameter or add the $logs content to the $LogOnRecords" variable.

    Also, you don't want to use "FT" to populate the $logs variable. The result isn't what you think it is.


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)


    Thursday, October 17, 2019 3:15 PM
  • I did , but I still did not received any information :(

    $ServerName = "myservername"
    $sender = "sender@email"
    $Subject = $ServerName + " - Check Disk Health " + $TimeNow.datetime
    
    
    $SmtpServer = "SMTPmyserver"
    
    $logs = Get-PhysicalDisk | Sort Size | FT FriendlyName, Size, MediaType, SpindleSpeed, deviceid, HealthStatus, IsOffline, OperationalStatus -AutoSize
    
        Send-MailMessage -To "my@email.com" -from $sender `
        -subject $Subject -Smtp $SmtpServer `
        -body $logs
    Thursday, October 17, 2019 3:38 PM
  •    Send-MailMessage -To "my@email.com" -from $sender `
        -subject $Subject -Smtp $SmtpServer `
        -body ($logs|Out-String)


    \_(ツ)_/

    • Marked as answer by Mooner09 Thursday, October 17, 2019 5:11 PM
    Thursday, October 17, 2019 4:28 PM
  • it's working coool thank you very much, 

    please could you tell me,  can somehow make lines so that it’s be clear, otherwise everything is together

    see below

    Thursday, October 17, 2019 4:54 PM
  • You have to send this as an HTML table. Search for many articles that will teach you how to create HTML mail bodies using 'ConvertTo-Html".

    Your original question has been answered.  Please mark the answer.  For any new questions about code you have written please open a new topic.


    \_(ツ)_/

    • Marked as answer by Mooner09 Thursday, October 17, 2019 5:12 PM
    • Unmarked as answer by Mooner09 Thursday, October 17, 2019 5:12 PM
    Thursday, October 17, 2019 5:11 PM