none
Dont show correctly RRS feed

  • Question

  • Hi,

    I did download en acript the should mail me the free space of my servers every day, if I put only one server in de DL.txt then I get a report, but when put more servers in the Dl.txt I get a mail with in it the free space of all of servers but what what shows in the mail is not foramted in correct way, if I open the FreeSpace.htm on the server where the script running from it shows in correct format but in email is not correct format,

    did download the code from: https://gallery.technet.microsoft.com/scriptcenter/6e935887-6b30-4654-b977-6f5d289f3a63


    Shahin

    Thursday, November 13, 2014 9:42 AM

Answers

  • Here is what the report looks like in email.  You can change the colors and style.

    Disk Space Report 11/13/2014 06:20:27

    SystemName

    DeviceID

    VolumeName

    FreeSpace (Gb)

    Size (Gb)

    OMEGA                  

    C:                

    OS                       

    634.17                   

    911.35         

    OMEGA

    F:

    DATA2

    224.73

    298.09

    OMEGA

    K:

    HP_RECOVERY

    2.47

    19.94

    W8TEST

    C:

    ACER

    319.42

    451.47


    ¯\_(ツ)_/¯


    • Edited by jrv Thursday, November 13, 2014 11:37 AM
    • Marked as answer by Shahin Thursday, November 13, 2014 1:36 PM
    Thursday, November 13, 2014 11:36 AM

All replies

  • The script is not designed correctly for email.  You will have to fix it or find a new script.


    ¯\_(ツ)_/¯

    Thursday, November 13, 2014 10:13 AM
  • Thanks for your reply,

    I spend almost 2 days to get this script to work finaly, and now I findout that the script is not correctly designs for email!! I download it from the thechnet center, shouldn't thechnet says This script is not designs for the mail??

    Thanks


    Shahin

    Thursday, November 13, 2014 10:19 AM
  • Anybody can post in TechNet. Perhaps the author liked the way it displayed in email.  You are free to modify the script as you need.

    Here is a simple script that works well in email:\

    $mailprops=@{
        SmtpServer='smtp.mydomain.com'
        To='jsmith@msn.com'
        From='gsmoot@mydomain.com'
        BodyAsHtml=$true
        Subject="Disk Space Report $([datetime]::Now)"
        UseSsl=$false
        Port=25
    }
    $style=@'
    <style type="text/css">
        h1 {
            color: darkblue
            font-weight: bolder;
            font-style: italic;
            font-size: 14pt;
        }
        body {
            background-color: lightyellow;
        }
        table {
            background-color: antiquewhite;
            border-style: solid;
            border-width: thin;
            border-collapse: collapse;
            border-style: thin;
            border-color:black;
        }
       td {
            border-style: solid;
            border-width: thin;
            border-color:darkblue;
        }
    </style>
    '@
    $servers=Get-Content servers.txt
    $body=Get-WmiObject win32_logicaldisk -ComputerName $servers -Filter 'DriveType=3'  -ea 0|
         Select-Object SystemName,DeviceID,VolumeName,@{L='FreeSpace (Gb)';E={'{0:N2}' -f ($_.FreeSpace/1Gb)}},@{N='Size (Gb)';E={'{0:N2}' -f ($_.Size/1Gb)}} |
         ConvertTo-Html -Head $style -Title $mailprops.Subject -PreContent "<h1>$($mailprops.Subject)</h1>" |
         Out-String
    Send-MailMessage @mailprops -Body $body
    
    It is also very easy to modify.


    ¯\_(ツ)_/¯

    • Proposed as answer by jrv Thursday, November 13, 2014 3:16 PM
    Thursday, November 13, 2014 11:33 AM
  • Here is what the report looks like in email.  You can change the colors and style.

    Disk Space Report 11/13/2014 06:20:27

    SystemName

    DeviceID

    VolumeName

    FreeSpace (Gb)

    Size (Gb)

    OMEGA                  

    C:                

    OS                       

    634.17                   

    911.35         

    OMEGA

    F:

    DATA2

    224.73

    298.09

    OMEGA

    K:

    HP_RECOVERY

    2.47

    19.94

    W8TEST

    C:

    ACER

    319.42

    451.47


    ¯\_(ツ)_/¯


    • Edited by jrv Thursday, November 13, 2014 11:37 AM
    • Marked as answer by Shahin Thursday, November 13, 2014 1:36 PM
    Thursday, November 13, 2014 11:36 AM