Skip to content
Massimo Bonvicini edited this page Aug 27, 2019 · 2 revisions

Description

Usage

> Add-LoggingTarget -Name Email -Configuration @{
    SMTPServer  = <NOTSET>          # <Required> SMTP server FQDN
    From        = <NOTSET>          # <Required> From address
    To          = <NOTSET>          # <Required> A string of recipients delimited by comma (,) (eg. '[email protected], [email protected]')
    Subject     = '[%{level:-7}] %{message}'    # <Not required> Email subject. Supports formatting and expansion
    Attachments = <NOTSET>          # <Not required> Path to the desired file to attach
    Credential  = <NOTSET>          # <Not required> If your server uses authentication
    Level       = <NOTSET>          # <Not required> Sets the logging format for this target
    Port        = <NOTSET>          # <Not required> Set the SMTP server's port
    UseSsl      = $false            # <Not required> Use encrypted transport to SMTP server
}

Write-Log -Level 'WARNING' -Message 'Hello, Powershell!'
Write-Log -Level 'WARNING' -Message 'Hello, {0}!' -Arguments 'Powershell'
Write-Log -Level 'WARNING' -Message 'Hello, {0}!' -Arguments 'Powershell' -Body @{source = 'Logging'}