Created
February 21, 2019 16:37
-
-
Save smaug9/1b17130e8ba73222b71d54199d39f70a to your computer and use it in GitHub Desktop.
send-htmltable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#send-htmltable.ps1 | |
[CmdletBinding()] | |
param ( | |
[Parameter( | |
Mandatory = $true, | |
ValueFromPipeline = $true, | |
#ValueFromPipelineByPropertyName = $true, | |
Position = 0)] | |
[ValidateNotNullOrEmpty()] | |
#[alias("name")] | |
[pscustomobject] | |
$inputobject, | |
[string] | |
$subject = "TPS Report" | |
) | |
begin { | |
write-verbose "begin block" | |
#$body = @() | |
#$results = @() | |
if (!$CSS){ | |
$CSS = @" | |
<style type="text/css"> | |
table { | |
font-family: Verdana; | |
border-style: dashed; | |
border-width: 1px; | |
border-color: #FF6600; | |
padding: 5px; | |
background-color: #FFFFCC; | |
table-layout: auto; | |
text-align: center; | |
font-size: 8pt; | |
} | |
table th { | |
border-bottom-style: solid; | |
border-bottom-width: 1px; | |
font: bold | |
} | |
table td { | |
border-top-style: solid; | |
border-top-width: 1px; | |
} | |
.style1 { | |
font-family: Courier New, Courier, monospace; | |
font-weight:bold; | |
font-size:small; | |
} | |
</style> | |
"@ | |
}#End if | |
$HTMLDetails = @{ | |
Title = $subject | |
Head = $CSS | |
} | |
} | |
process { | |
write-verbose "process block" | |
#$body += $inputobject | |
$body = foreach ($obj in $inputobj) { | |
} | |
} | |
end { | |
write-verbose "end block" | |
$smtpargs = @{ | |
to = "me@asdf.com" | |
from = "me@asdf.com" | |
subject = $subject | |
smtpserver = "mail.google.com" | |
#body = "Body01" | |
#body = $results | ? {$_.encrypted -eq $false} | sort cluster, vmname | ConvertTo-Html @HTMLDetails | out-string | |
body = $body | ConvertTo-Html @HTMLDetails | out-string | |
bodyashtml = $true | |
} #end $smtpargs | |
Send-MailMessage @smtpargs | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment