Cette fonction permet d'envoyer par mail un hashtable :
Exemple d'utilisation :
get-process | send-htmlemail - from test@test.com -to toto@test.com -subject "Process List"
function Send-HTMLEmail { #Requires -Version 2.0 [CmdletBinding()] Param ([Parameter(Mandatory=$True, Position = 1, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] $InputObject, [Parameter(Mandatory=$True, Position = 2, HelpMessage="Please enter the To address")] [Array]$To, [Parameter(Mandatory=$True, Position = 3, HelpMessage="Please enter the Subject")] [String]$Subject, [String]$From = "user@domain.org", # Pretty table CSS is available for download # http://gallery.technet.microsoft.com/scriptcenter/c63025ef-645d-4efe-a4c3-bc126cb939e8 [String]$CSS = "C:\PwShell\Html_Report.css", [String]$SmtpServer ="smtp.server.com" )#End Param $HTMLDetails = @{ Title = $Subject Head = (get-content -Path $CSS) } $htmlinfo = $InputObject | ConvertTo-Html @HTMLDetails $Splat = @{ To =$To Body ="$htmlinfo" Subject =$Subject SmtpServer =$SmtpServer From =$From BodyAsHtml =$True } Send-MailMessage @Splat }Fichier CSS :
Ma première page avec du style
Aucun commentaire:
Enregistrer un commentaire