none
Need a Powershell Script to get DPM Jobs status in html or excel format. RRS feed

  • Question

  • I have created a script to fetch DPMJobs status in html format and email output to recipients. I am not very good in html, I need some modified output such as failed jobs values 'FAILED' should be in dark red background, ProtectionGroupNames should be merged to one column instead of repeating. If anyone can modify this script, please do...... I have attached the output. You can see the quality of output and can check for improvements in it. (I have modified output content data for privacy, please ignore content)

    Here is the script:


    $ErrorActionPreference = "silentlycontinue"

    Connect-DPMServer  test.abc.com


    $a = "<style>"
    $a = $a + "BODY{background-color:peachpuff;}"
    $a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
    $a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}"
    $a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:palegoldenrod}"
    $a = $a + "</style>"
               
    Get-DPMJob | Select-Object -Property ProtectionGroupName, DataSources, JobType, Status, StartTime, EndTime, DataSize, JobDefinitionMarkedForDeletion | Sort-Object "ProtectionGroupName" | ConvertTo-HTML -head $a | Out-File C:\DPM.htm


    $file = "C:\DPM.htm"

    $smtpServer = "email@abc.com"


    $att = new-object Net.Mail.Attachment($file)


    $msg = new-object Net.Mail.MailMessage


    $smtp = new-object Net.Mail.SmtpClient($smtpServer)


    $msg.From = "DPMAlerts@abc.com"


    $msg.To.Add("vijay@abc.com")


    $msg.Subject = "DPM Alerts summary since last 24 hours"


    $msg.Body = "DPM Alerts summary since last 24 hours"


    $msg.Attachments.Add($att)


    $smtp.Send($msg)


    $att.Dispose()


     
    Thursday, December 19, 2013 4:12 PM